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
augiewazaugiewaz 

OutputPanel not Rerendering

Hi,


I have been working on something all day where an outputPanel gets rendered on a page after a user does a search.
For some reason and I cannot work out why, a hidden outputPanel does not render after a user clicks on a commandButton.

 

Below is my code. I have taken things out which are not neccessary

 

Any help would be appreciated.

 

Thanks
Warren

 

<apex:page sidebar="false" showHeader="false" controller="SearchProjectsController">
   <apex:form id="form"> 
      <apex:commandButton value="Search Projects" action="{!searchProjects}" reRender="projectList" />
      <apex:outputPanel id="projectList" rendered="{!doneSearch}">
         OPEN PROJECTS
      </apex:outputPanel>
   </apex:form>
</apex:page>


public class SearchProjectsController {

   public boolean doneSearch {get; set;}

   public SearchProjectsController() {
      doneSearch = false;
   }

   public PageReference searchProjects() {
      doneSearch = true;
      projects = [SELECT Id, Name, Title__c FROM Project__c];
      return null;
   }
}

 

Best Answer chosen by Admin (Salesforce Developers) 
ShamilShamil

Warren,

 

You need to wrap your outputPanel with another one:

 

<apex:page sidebar="false" showHeader="false" controller="SearchProjectsController">
   <apex:form id="form"> 
      <apex:commandButton value="Search Projects" action="{!searchProjects}" reRender="projectList" />
      <apex:outputPanel id="projectList">
      <apex:outputPanel rendered="{!doneSearch}">
         OPEN PROJECTS
      </apex:outputPanel>
</apex:outputPanel>
   </apex:form>
</apex:page>

 

The rule here is that you need to rerender a container so that whatever is inside it gets rerendered.

 

-Shamil

All Answers

ShamilShamil

Warren,

 

You need to wrap your outputPanel with another one:

 

<apex:page sidebar="false" showHeader="false" controller="SearchProjectsController">
   <apex:form id="form"> 
      <apex:commandButton value="Search Projects" action="{!searchProjects}" reRender="projectList" />
      <apex:outputPanel id="projectList">
      <apex:outputPanel rendered="{!doneSearch}">
         OPEN PROJECTS
      </apex:outputPanel>
</apex:outputPanel>
   </apex:form>
</apex:page>

 

The rule here is that you need to rerender a container so that whatever is inside it gets rerendered.

 

-Shamil

This was selected as the best answer
b-Forceb-Force

If above trick didn't work, rerender form object directly, It will work 

 

Thanks,

bForce

augiewazaugiewaz

Thanks Shamil!!

 

It did the trick