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
KeithJKeithJ 

rendered attribute for pageBlockSection not working for me

Hi there.
I am utilizing the pageBlockSection component and would like to render
it if a selectList (dynamically populated) is not empty.
Alas, it will not work.
Below is the section of my VF page that shows the pageBlockSection with the rendered attribute. I have double checked
and the variable isProductCategoryNotNone changes accordingly, but the pageBlockSection always remains invisble....
Any ideas? I use this variable earlier in my code to show another list and it works fine but wont work for the pageBlockSection.
Thanks
 

Code:
<!-- Define the Products List now... -->
<apex:pageBlockSectionItem >
<apex:outputPanel id="productLabelPanel">
<apex:outputLabel value="Products" for="productsList" rendered="{!isProductCategoryNotNone}" />
</apex:outputPanel>
<apex:outputPanel id="productListPanel">
<apex:selectList value="{!selectedProduct}" multiSelect="false" size="1" rendered="{!isProductCategoryNotNone}" id="productsList">
<!-- Add the products to the page for the selected Category -->
<apex:selectOptions value="{!allProducts}" />
<!-- Add an actionSupport to query for all Constituents for the selected product -->
<apex:actionSupport event="onchange" action="{!queryForSKUs}" status="queryStatus" rerender="SKUTable" />
</apex:selectList>
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>


<apex:pageBlockSection title="Available SKU's" columns="1" rendered="{!isProductCategoryNotNone}">
<apex:pageBlockTable columns="5" id="SKUTable" var="skuRecord" value="{!skuRecordsList}">
<apex:column>



FrancoFranco
See my code above asking about querying accounts.  I'm using the rendered attribute but, I've found that I have to wrap it with an extra outputpanel.
 
Code:
<apex:outputpanel title="Results" id="MyPanel">
  <apex:outputpanel title="Wrapper" id="Wrapper" rendered="{!NOT(ISNULL(SAcct))}">
    <apex:pageBlock >
      <apex:pageBlockTable title="Accounts" id="PickAccts" value="{!SAcct}" var="aAcct" >
        <apex:column headerValue="Account Id" value="{!aAcct.theacct.Id}" />
        <apex:column headerValue="Account Name" value="{!aAcct.theacct.Name}" />
      </apex:PageblockTable>
    </apex:Pageblock>
  </apex:outputpanel>
</apex:outputpanel>

 

KeithJKeithJ
Hi Franco.
Thanks for the reply.
I'm looking to use a pageBlockSection instead of an outputPanel.
I can't understand why it won't work.
Seems straightforward and the debug log shows that the boolean is changing as required...
KeithJKeithJ
Figured it out.
Had to do a rerender on the outermost pageBlock.
Why....? I have no idea, but it works
jwetzlerjwetzler
If you have a component on your page and set rendered="false", that component is not going to be encoded as HTML onto your page -- according to your page it doesn't exist.  Therefore, if you ask that same component to now render itself by referring to its id, we won't be able to find your component because its ID is not located on the page.  You have to ask an outer component to rerender so that it will re-encode its children and perform your rendered operation again.

Make sense?  A little confusing at first but you have to make sure that what you're rerendering on your page is actually going to be there.
KeithJKeithJ
Thanks for that explanation Jill!
It does make sense in fact.
I'll make sure to duly note that one for future reference.
I'm sure this kind of thing will come up again and again,
Best regards
NakataNakata

Hi KeithJ,

 

How to rerender at the outermost pageBlock in your case ?

 

Thank you !