You need to sign in to do that
Don't have an account?

Problem changing Rendered attribute due to order of execution
Visualforce:
<apex:pageBlockSectionItem rendered="{!boolVal}">
<apex:outputLabel value="Test1" />
<apex:inputText value="{!t.value1}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem rendered="{!NOT(boolVal)}">
<apex:outputLabel value="Test2" />
<apex:inputText value="{!t.value2}"/>
</apex:pageBlockSectionItem>
Apex:
public object temp;
public object getT() {
if (temp == null && ApexPages.currentPage().getParameters().get('id') != null)
temp = [SELECT value1, value2 FROM object WHERE Id = :ApexPages.currentPage().getParameters().get('id') LIMIT 1];
if (temp.value2 == 'sampleval')
setBool(true);
else
setBool(false);
return temp;
}
public boolean bool;
public boolean getBoolVal() {
if (bool == null)
bool = True;
if (temp != null && temp.value2 != 'sampleval')
bool = False;
return bool;
}
public void setBoolVal(boolean b) {
bool = b;
}
I am trying to dynamically show/hide the pageBlockSectionItems shown in the vf code above. It seems that the rendering of these pageBlockSectionItems happens before the apex code gets to the getT function. Is there a way to prioritize the order of apex calls or rerender the pageBlockSectionItems if the boolean value changes?
All Answers
This runs before the page loads.
public pageReference setConditionsToTrue() {
// if the query returns results show the section if(oneTimeSetupFeeQuery.size()>0){oneTimeSetupFeeSection = true;}
if(monthlyFeeQuery.size()>0){monthlyFeeSection = true;} return null;}
<apex:page action="{!setConditionsToTrue}></apex:page>