1

I am working on VF page - when I change the value of a picklist field then my pageblock table will show.

VF code

<apex:page sidebar="false" controller="AllObjectCtrl">
<apex:form>
   <apex:pageBlock title="All Objects in Org">
       <apex:pageBlockSection> 
           <apex:selectList value="{!objectName}" size="1">
               <apex:selectOptions value="{!Name}">
                   <apex:actionSupport event="onChange" action="{!getrecords}" reRender="tableShow"/>
               </apex:selectOptions>           
           </apex:selectList>

           <apex:pageBlockTable value="{!selectedObj}" var="a" id="tableShow">
               <apex:column value="{!a}" headerValue="ID"/>
           </apex:pageBlockTable>
       </apex:pageBlockSection>
   </apex:pageBlock>
</apex:form>

3
  • 1
    What is the actual problem here? Commented Jul 3, 2015 at 6:03
  • The code is not working... Commented Jul 3, 2015 at 6:09
  • Can you please also post the getrecords method as well as other relevant backend code? Commented Jul 3, 2015 at 6:13

3 Answers 3

2

you are using this thats why it is not running

<apex:actionSupport event="onChange" action="{!getrecords}" reRender="tableShow"/>

because the even="OnChange"is a java script finction and as java script is a case sensetive language so rather then using Capital c on onChnage use small "c" in onchange like this :

<apex:actionSupport event="onchange" action="{!getrecords}" reRender="tableShow"/>
0

The actionSupport should be a child of selectList. Example:

<apex:selectList value="{!objectName}" size="1">
    <apex:actionSupport event="onChange" action="{!getrecords}" reRender="tableShow"/>
    <apex:selectOptions value="{!Name}"/>
</apex:selectList>

You can use actionFunction and onchange selectList attribute. Example:

<apex:actionFunction name="getRecordsJS" action={!getrecords} reRender="tableShow"/> 

<apex:selectList value="{!objectName}" size="1" onchange="getRecordsJS();">
    <apex:selectOptions value="{!Name}"/>
</apex:selectList>

Best regards

0

Torsen's answer should resolve your problem, but if there would be still something wrong, make sure to always add the <apex:pagemessages /> somewhere in the page, in development phase. Rerender errors are sometimes hard to debug and the reasons might be catchy, like - nothing happens when any required field is not filled, nothing happens when you populate picklist from set etc...

You must log in to answer this question.

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