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

How to reRender components dynamically
Hi,
I have a component. It is a form with 2 fields. I don't know a priori which field will be rendered. I have a method in my controller that tells if the field should be displayed or not, the name of the field has to be passed:
public Boolean displayField(String fieldName){
if(fieldName!=null){
for(String field : fields){
if(fieldName.compareTo(field)==0){
return true;
}
}
}
return false;
}
And within my component I want to be able to call the method from the rendered attribute:
<apex:outputPanel rendered="">
<apex:outputLabel value="First Name:" for="firstName"/>
<apex:inputText id="firstName" value="{!ControllerCase.HEAT_First_Name__c}" styleclass="text"/>
</apex:outputPanel>
<apex:outputPanel rendered="">
<apex:outputLabel value="Surname:" for="surname"/>
<apex:inputText id="surname" value="{!ControllerCase.HEAT_Surname__c}" styleclass="text"/>
</apex:outputPanel>
Is there a way to do so?
i dont know whther thers a way to call a method from rendered attribute..
but this might work...
in your controller declare a property..
Boolean tobeRendered { get;set;}
and then call the method in ur constructor
tobeRendered = displayField(filedname);
and in outputPanel rendered= "{!tobeRendered}"
All Answers
i dont know whther thers a way to call a method from rendered attribute..
but this might work...
in your controller declare a property..
Boolean tobeRendered { get;set;}
and then call the method in ur constructor
tobeRendered = displayField(filedname);
and in outputPanel rendered= "{!tobeRendered}"
Hi,
Thanks for the help!
it sounds like the only option but in that case I will need yo have a property per field right?
yes..