function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CreatobugCreatobug 

Reloading the contents of the page on a click of command button!

Hey can anyone Help me understand why this doesn't work and suggest a work around?

 

VF page:

 

<apex:page controller="paneltest">

    <apex:form >
    <apex:commandbutton action="{!settabpanel1}" value="tabcol1" rerender="outputpanel1,outputpanel2,outputpanel3"/>
    <apex:commandbutton action="{!settabpanel2}" value="tabcol2" rerender="outputpanel1,outputpanel2,outputpanel3"/>
    <apex:commandbutton action="{!settabpanel3}" value="tabcol3" rerender="outputpanel1,outputpanel2,outputpanel3"/>
    <apex:outputpanel rendered="{!showpanel1}" id="outputpanel1">
        Panel1
    </apex:outputpanel>
    <apex:outputpanel rendered="{!showpanel2}" id="outputpanel2">
        panel2
    </apex:outputpanel>
    <apex:outputpanel rendered="{!showpanel3}" id="outputpanel3">
        Panel3
    </apex:outputpanel>
</apex:form>
</apex:page>

 

Controller:

 

public class paneltest
{
    public boolean showpanel1 {get;set;}
    public boolean showpanel2 {get;set;}
    public boolean showpanel3 {get;set;}
    public boolean getShowpanel1()
    {
        return showpanel1;
    }
    public boolean getShowpanel2()
    {
        return showpanel2;
    }
    public boolean getShowpanel3()
    {
        return showpanel3;
    }
    public paneltest()
    {
        showpanel1=true;
        showpanel2=false;
        showpanel3=false;
    }
    public pagereference settabpanel1()
    {
        showpanel1=true;
        showpanel2=false;
        showpanel3=false;
        return null;
    }
    public pagereference settabpanel2()
    {
        showpanel1=false;
        showpanel2=true;
        showpanel3=false;
        return null;
    }
    public pagereference settabpanel3()
    {
        showpanel1=false;
        showpanel2=false;
        showpanel3=true;
        return null;

    }
 
}

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

This will almost certainly be because you are trying to rerender something that wasn't rendered in the first place.  I wrote a blog post about this at:

 

http://bobbuzzard.blogspot.com/2011/02/visualforce-re-rendering-woes.html

All Answers

bob_buzzardbob_buzzard

This will almost certainly be because you are trying to rerender something that wasn't rendered in the first place.  I wrote a blog post about this at:

 

http://bobbuzzard.blogspot.com/2011/02/visualforce-re-rendering-woes.html

This was selected as the best answer
CreatobugCreatobug

WOW that was an amazing blog!........Thank you so much....Not just for providing a solution but also for explaining the nuances behind it :D......