You need to sign in to do that
Don't have an account?
apex:actionsupport onclick event is not working
Hi,
I have two output panels, by default first panel should display. when i click on command button in panel1, panel2 should display. If i click on command button in panel2 , then the panel1 should display. Onclick event is not working.
VF Page
-------------
<apex:page controller="ActionSupport_OnClick">
<apex:form >
<apex:outputPanel id="selectText">
<apex:pageBlock rendered="{!show}" id="selectPub1">
<apex:outputlabel id="label" value="1st Panel"/>
<apex:commandbutton id="change" value="change">
<apex:actionSupport event="onclick" action="{!InvokeShow}" rerender="selectText,selectValues"/>
</apex:commandbutton>
</apex:pageBlock>
</apex:outputPanel>
<apex:outputPanel id="selectValues">
<apex:pageBlock rendered="{!hide}" id="selectPub2">
<apex:outputtext id="text" value="2nd Panel"/>
<apex:commandbutton id="modify" value="modify">
<apex:actionSupport event="onclick" action="{!Invokehide}" rerender="selectText,selectValues"/>
</apex:commandbutton>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>
Controller
---------------
public with sharing class ActionSupport_OnClick {
public boolean show{get;set;}
public boolean hide{get;set;}
public ActionSupport_OnClick(){
show=true;
hide=false;
}
public void InvokeShow()
{
show=false;
hide=true;
system.debug('Inside InvokeShow:');
}
public void Invokehide()
{
show=true;
hide=false;
}
}
Thanks.
Hi,
Why r u using actionsupport on apex:commandButton,because commandButton already have their action attribute.
U can modify uor code as below:
<apex:page controller="ActionSupport_OnClick">
<apex:form >
<apex:outputPanel id="selectText">
<apex:pageBlock rendered="{!show}" id="selectPub1">
<apex:outputlabel id="label" value="1st Panel"/>
<apex:commandbutton id="change" value="change" action="{!InvokeShow}" rerender="selectText,selectValues"/>
</apex:pageBlock>
</apex:outputPanel>
<apex:outputPanel id="selectValues">
<apex:pageBlock rendered="{!hide}" id="selectPub2">
<apex:outputtext id="text" value="2nd Panel"/>
<apex:commandbutton id="modify" value="modify" action="{!Invokehide}" rerender="selectText,selectValues" />
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>
And u can do this with asingle boolean variable as:
<apex:pageBlock rendered="{!show}" id="selectPub1">
<apex:pageBlock rendered="{!NOT(show)}" id="selectPub2">
Please let me know if u have any problem on same and if this post helps u please throw KUDOS by click on star at left.