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

control which fields are rendered in an output panel
I have approximately 20 fields in an output panel and I only want to display fields that have a value and hide the ones that do not.
I'm using a render tag for each field-rendered="{!IF(NOT(ISNULL(Contract__c.Status)),true,false)}"
Instead of using a render tag for each field, is there a way of inserting a tag in the output panel to do this? If so, how?
Hi Spunki
Please make Custom Object named Book and Field Title ,Author , ...etc
Now refer my code....
<apex:page controller="Renderfieldcontroller">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection columns="2" title="Book Information" rendered="{!Enable!='show'}">
<apex:repeat value="{!threeFieldList}" var="afield" >
<apex:inputField value="{!Book[afield]}" />
</apex:repeat><br/>
<apex:commandButton value="Save" action="{!savingBook}"/>
</apex:pageBlockSection>
<apex:pageBlockSection columns="2" title="Book Information" rendered="{!Enable=='show'}">
<apex:repeat value="{!threeFieldList}" var="afield" >
<apex:outputField value="{!Book[afield]}" rendered="{!IF(NOT(ISNULL(Book[afield])),true,false)}" />
</apex:repeat><br/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
My controller is......
public class Renderfieldcontroller {
List<string>threeFieldList{get; set;}
public final Book__c bok{get;set;}
public String Enable{get;set;}
public Renderfieldcontroller () {
bok = new Book__c ();
if (threeFieldList == null) {
threeFieldList = new List<String>();
threeFieldList.add('Author__c');
threeFieldList.add('Price__c');
threeFieldList.add('Publisher__c');
threeFieldList.add('Title__c');
}
}
public List<String> getthreeFieldList()
{
return threeFieldList;
}
public Book__c getBook() {
return bok;
}
public PageReference savingBook() {
upsert bok;
Enable = 'show';
return null;
}
}
Did this answer of your Question ? If so then please mark it solved....
thanks
asish