3

I am working with with picklist. Here I have to show a pageblocksection on change picklist but when I change the picklist it rerenders all the page and I am able to see pageblocksection but my picklist option get vanish from the page. Below is my code please check!

 <span id="idSpan" style = "display:none"> 
           <apex:pageBlockSection title="Search For Public Group" columns="1" id="Details"> 
               <apex:selectList size="1" value="{!selectedgrpId}">  
                   <apex:selectOptions value="{!GroupNames}"/>
                   <apex:actionSupport event="onchange" />
               </apex:selectList>
           </apex:pageBlockSection> 
       </span>

I have to show below pageblocksection.

<apex:pageBlockSection title="Enter User Id" columns="1" id="sec1" rendered="{!selectedgrpId != null}"> 
           <apex:inputTextArea value="{!UserId}"/> 
           <apex:commandButton value="Submit" action="{!useraddition}"/>   
       </apex:pageBlockSection>

2 Answers 2

3

You have two problems here:

  1. Check Anurag answer. Your action support need to reRender something.
  2. It's a common mistake with reRender. You can't reRender an element that was never rendered on the page (because the page won't find the Id). Instead, you have to reRender a parent element wich will trigger the evaluation of the rendered attributte of it's children. Try something like this:
<span id="idSpan" style = "display:none"> 
    <apex:pageBlockSection title="Search For Public Group" columns="1" id="Details"> 
        <apex:selectList size="1" value="{!selectedgrpId}">  
            <apex:selectOptions value="{!GroupNames}"/>
            <apex:actionSupport event="onchange" reRender="wrapper" />
        </apex:selectList>
    </apex:pageBlockSection> 
</span>

<apex:outputPanel layout="none" id="wrapper">
    <apex:pageBlockSection title="Enter User Id" columns="1" id="sec1" rendered="{!selectedgrpId != null}"> 
        <apex:inputTextArea value="{!UserId}"/> 
        <apex:commandButton value="Submit" action="{!useraddition}"/>   
    </apex:pageBlockSection>
</apex:outputPanel>
2

You may have to modify the action support with following syntax:

<apex:actionSupport event="onchange" rerender="sec1" />
1
  • I have checked with this but didnt work. By this, pageblocksection is not rerendering.
    – SFDC 44
    Commented Oct 11, 2016 at 8:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .