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
lopezclopezc 

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?

 
Message Edited by lopezc on 04-01-2010 03:10 AM
Best Answer chosen by Admin (Salesforce Developers) 
Shailesh DeshpandeShailesh Deshpande

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

Shailesh DeshpandeShailesh Deshpande

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}"

 

This was selected as the best answer
lopezclopezc

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?

Shailesh DeshpandeShailesh Deshpande

yes..