Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am tying to hide and show apex:pageblocker on the bases of the value in list. But i am not able to show when value is not been selected. My anybody tell me what is wrong. I am getting value in the pageblockTable.

my code:

     <apex:commandButton action="{!addSelected}" value="Add Selected" reRender="id_ViewSelectedItem"/>

     <apex:pageBlock title="Selected Installed Items" id="id_ViewSelectedItem"  rendered="{!IF(theInstalledItem_checkedView.size>0, true, false)}">
     <apex:pageBlockTable value="{!theInstalledItem_checkedView}" var="ins" >
share|improve this question
    
I tried in this way also rendered="{!theInstalledItem_checkedView != null || theInstalledItem_checkedView.size>0}" –  AnuRaj Jan 22 '13 at 11:29
    
What is the problem? What you can not to show? –  mast0r Jan 22 '13 at 11:54

1 Answer 1

It seems to be related to the use of 'reRender' on your commandButton. I am not 100% why, the docs don't seem to indicate any restrictions around targeting components in a rerender that then use the rendered attribute. So this could be a VF bug. Anyway here are a couple of ways to get this to work as your expecting...

  • If you remove the 'reRender' attribute it works
  • If you add an outer panel wrapping the page block section it works.

My test code (slightly adapted from your sample) below, reflects the second option above.

<apex:page controller="HideAndShowController">
    <apex:form>
        <apex:commandButton action="{!addItem}" value="Add Item"
            reRender="outerPanel" />
        <apex:outputPanel id="outerPanel">
            <apex:pageBlock title="Selected Installed Items"
                id="id_ViewSelectedItem"
                rendered="{!IF(myList.size > 0, true, false)}">
                <apex:pageBlockTable value="{!myList}" var="ins">
                    <apex:column value="{!ins}" />
                </apex:pageBlockTable>
            </apex:pageBlock>
        </apex:outputPanel>
    </apex:form>
</apex:page>

Update: This blog from Bob Buzzard offers further insight into this issue. Nice one Bob!

share|improve this answer
    
Interesting article. I always assumed it was something to do with the fact that because the reRender action only re renders the element's children, excluding itself (which I found made some kind of sense to me) –  Ben Jan 22 '13 at 17:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.