I'm using rendered in my visualforce page but I'm not sure if I fully grasp it's behavior.

If I'm using <apex:outPutPanel rendered="{!test}">, and test (in my controller) switches from true to false, will the visualforce page immediately hide it? Or will I need to rerender this output panel?


1 Answer 1


You do need to perform a partial page rerender to get the output panel to disappear when the value of {! test } changes.

However, it's best to use an outer component as the target of your rerender operations when using a rendered attribute. This is because when rendered is false, the entire component is never even sent to the client. It's just dropped when the page is rendered by the server, which means that if you tried to rerender it after your condition changed back to true, nothing would happen - the component's not there!

It's best to use a structure like this:

<apex:outputPanel id="rerenderTarget">
    <apex:outputPanel rendered="{!test}">
        <!-- Stuff goes here -->

Then, your <apex:commandButton>s and other components can have reRender="rerenderTarget", and you can be confident that your inner <apex:outputPanel> will always be shown or hidden correctly based on the current value of the expression {! test }.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .