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
bunrothabunrotha 

Multi-select picklist not firing event for AJAX refreshes

I have a particular oddity in a VF page.

 

I'm trying to show or hide fields based on picklists, so if the user picks a certain option, they get prompted for more detail, or if they pick anything off a multi-select picklist, they get asked for detail.

 

This works fine for a single option picklist, but not on a multi-select picklist.

When I change the multi-select picklist, there's no indication of any activity, the status message doesn't change, and no refresh.  I'm using IE8.

 

With the single-option picklist, I found I had to use an outputpanel to get the rerender to work, if I put the rerender into the pageblocksectionitem itself, it never behaved.

 

Here's some code, no controller just a custom object, can anyone see if I've cocked this up or not please?

 

<apex:inputfield value="{!object__c.themultiselectpicklist__c}"> <apex:actionsupport event="onchange" rerender="esref" status="stat"/> </apex:inputfield> <apex:outputPanel id="esref"> <apex:pageblocksectionItem rendered="{!TICK__c.object__c.themultiselectpicklist__c!=''}"> <apex:outputLabel value="Have you been provided with any reference numbers?"/> <apex:inputField value="{!object__c.Ref_Numbers__c}"/> </apex:pageblocksectionItem> </apex:outputPanel> <apex:inputfield value="{!Object__C.singleoptionpicklist__c}"> <apex:actionsupport event="onchange" rerender="witlist" status="stat"/> </apex:inputfield> <apex:outputPanel id="witlist"> <apex:pageblocksectionItem rendered="{!Object__C.singleoptionpicklist__c='Yes'}" > <apex:outputlabel value="Please list the names"/> <apex:inputtextarea cols="120" rows="5" value="{!Tick__c.namelist__c}"/> </apex:pageblocksectionitem> </apex:outputpanel> <apex:actionstatus id="witstat" starttext="Working" stoptext="Ready"> </apex:actionstatus>

 

Best Answer chosen by Admin (Salesforce Developers) 
jwetzlerjwetzler
Are you still seeing this?  This should have been fixed with the Spring '10 release.

All Answers

jwetzlerjwetzler
Are you still seeing this?  This should have been fixed with the Spring '10 release.
This was selected as the best answer
bunrothabunrotha

Hi Jill-

 

it's certainly OK in my sandbox, so it looks like Spring 10 has done the trick.

 

Thankyou kindly, and Hurray for fixes!

usupportedusupported

 

I'm trying to use essentially the same idea as above, with the single-select picklist used to determine which input field below is rendered, but I am having no luck. As far as I can tell with Firebug, the onchange event isn't firing. Am I doing something obviously egregious? Does the onchange event even work within and inputField actionAsupport element? 

 

<apex:inputField value="{!Call_Report__c.Topic__c}" id="topic" > 

               <apex:actionSupport event="onchange" reRender="tickerInput,sectorInput,bondInput">  

                 <apex:param name="topicSelection" value="{!Call_Report__c.Topic__c}" /> 

                </apex:actionSupport> 

 </apex:inputField>

 <apex:inputField value="{!Call_Report__c.Tickers__c}" rendered="{!Call_Report__c.Topic__c='Issuer'}" id="tickerInput" />            <apex:inputField value="{!Call_Report__c.Sector__c}" rendered="{!Call_Report__c.Topic__c='Industry'}" id="sectorInput"/>            <apex:inputField value="{!Call_Report__c.Security__c}" rendered="{!Call_Report__c.Topic__c='Specific Bond'}" id="bondInput" />

 

jwetzlerjwetzler

So you've got a couple things wrong with what you're doing.  The first is that you don't need a param component.  When the actionSupport fires, it will call the setter on your picklist and set the value so that it can be referenced by your other fields.

 

The other problem is that you can't rerender something that's not on your page.  You are probably referencing ids that don't exist.  For example, your "tickerInput" field will not be on your page if the picklist is not set to "Issuer", so once you actually do set your picklist to "Issuer", the actionSupport can't find the id of your component to rerender it, since it's not there.  So what you probably want to do is surround those last few inputFields with an outputPanel (which has no rendered attribute) with id="fieldPanel" or something similar, and then rerender "fieldPanel" instead of the three ids you've referenced.  Alternatively if this is inside of a pageBlock or something and you don't want to add an outputPanel, you can just rerender the parent pageBlock.  Does that make sense?

 

Finally, you may also be having a problem with validations.  actionSupport (and all other action components) do a form submit, so if there are required fields on your page or something, it may be trying to submit those fields whenever you change the value of your picklist, so the action may not ever really fire.  You can put the pageMessages component somewhere on your page to see if there are any validation errors.  The way to get around this is to surround your picklist field with an apex:actionRegion, which will tell the actionSupport to only submit what's in the region when it posts back to the server.

 

See these examples:

 

<apex:page standardController="Account">
  <apex:form>
    <apex:inputField value="{!account.industry}">
      <apex:actionSupport event="onchange" rerender="field1"/>
    </apex:inputField>
    <apex:outputText value="{!account.industry}" id="field1"/>
  </apex:form>
</apex:page>

 Notice that the above example works because the outputText is always rendered.

 

<apex:page standardController="Account">
  <apex:form>
    <apex:actionRegion>
      <apex:inputField value="{!account.industry}">
        <apex:actionSupport event="onchange" rerender="thePanel"/>
      </apex:inputField>
    </apex:actionRegion>
    <apex:outputPanel id="thePanel">
      <apex:inputField value="{!account.name}" rendered="{!account.industry=='Agriculture'}"/>
      <apex:inputField value="{!account.description}" rendered="{!account.industry=='Banking'}"/>
    </apex:outputPanel>
  </apex:form>
</apex:page>

 And note that this example rerenders the whole outputPanel because those fields won't exist on your page until you've selected either Agriculture or Banking from your account picklist.  Furthermore, it requires an actionRegion because account.name is a required field.  So if you remove the actionRegion and select Agriculture from your picklist, it will render the name field, and then if you try to select something else it will complain that name is a required field.  actionRegion prevents the name field from being submitted during the onchange of your picklist.

 

usupportedusupported

Jill,

 

Thanks so much for this clarification. I've gotten things working with your assistance. Are there plans to add either support for Visualforce to the Basic Support package, or plans to enrich the documentation? These would be greatly appreciated by every developer trying to use Visualforce.

 

Regards,

 

Ben