You need to sign in to do that
Don't have an account?
rerendering a pageblock that wasn't rendered before
Hello,
I try to rerender a pageblock that wasn't rendered before. In the page the user can select articles and add them as orderpositions to an order. When he comes here for the first time there are no orderpositions and I want to hide the pageblock. But that does not work. Here is my code:
<apex:page standardController="Auftragsposition__c" extensions="BarVerkaufWizardController" tabStyle="Auftragsposition__c" >
<apex:form ID="Artikelform">
...
<apex:PageBlock ID="ArtikelBar "rendered="{!Bar_prop}">
<apex:pageBlockSection title="ausgewaehlte Artikel Bar" collapsible="false" id="selectedArtBar" rendered="{!Bar_prop}">
<apex:pageBlockTable value="{!BVAposlisteBar}" var="AP" id="selectedPBTableBar" rendered="{!Bar_prop}">
... //some columns
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
...
<apex:pageBlock ID="Artikelblock">
<apex:actionStatus id="Status" starttext="Suche..."/>
<apex:pageBlockTable value="{!Artikelliste}" var="Art" id="Artikeltable">
<apex:column headerValue="Bar">
<apex:commandButton action="{!SelectedArtBar}" rerender="ArtikelBar,selectedArtBar,selectedPBbTableBar,Gesamtpreis" value="Bar">
<apex:param name="b" assignTo="{!applyArtId}" value="{!Art.ID}"/>
</apex:commandButton>
</apex:column>
... //some more columns
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
And here is the controller code:
public Boolean Bar_prop{
get{
Boolean bar = True;
system.debug ('################### Länge BVAposlisteBar ' + BVAposlisteBar.size());
if (BVAposlisteBar.size() == 0){
bar = False;
}
system.debug ('################### Bar Tabelle anzeigen ' + bar);
return bar;
}
set;
}
The system sets the right value for Bar_prop and it gets true if the user selects an article, but if the Pageblock and the pageblocksection weren't rendered before, they are not rendered. If only the pageblocktable wasn't rendered before, everything runs as expected.
Where is the problem?
Thanks in advance!
Harry
The rerender should be one level higher than the element you want to render.
You rerender the container to catch the render on the item.
All Answers
The rerender should be one level higher than the element you want to render.
You rerender the container to catch the render on the item.
Thanks Dan,
this works, but isn't it possible even to hide the pageblock before it is used?
Thanks
Harry
Put the rerender on the form and than you can use the render attribute on the PageBlock.
Hi Dan,
Thanks a lot! That works!
Harry