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

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:pageBlockSection columns="2" title="Book Information" rendered="{!Enable!='show'}">
          <apex:repeat value="{!threeFieldList}" var="afield" >
              <apex:inputField value="{!Book[afield]}"  />
          <apex:commandButton value="Save" action="{!savingBook}"/>
       <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)}"  />


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>();
      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....