You need to sign in to do that
Don't have an account?
can't attach an ajax event to a multi-picklist?
I am having trouble attaching an ajax event to a multi-picklist.
I want to display the text field Case.Other_Categories__c if and only if if "Other" is selected in the multi-picklist Case.Categories__c.
public Boolean displayOther { get { return theCase.Categories__c != null && theCase.Categories__c.contains('Other'); } }
<apex:pageBlockSection> <apex:actionregion immediate="true"> <apex:inputField value="{!Case.Categories__c}"> <apex:actionSupport event="onblur" rerender="other_categories" status="updating_other_status"/> </apex:inputField> </apex:actionregion> <apex:inputField value="{!Case.Other_Categories__c}" rendered="{!displayOther}" id="other_categories"/> <apex:actionStatus startText="updating..." id="updating_other_status" /> </apex:pageBlockSection>
I've tried onclick, onchange, ondblclick, and onblur events, but I never see the actionstatus displayed, and watching in firebug I never see an ajax submit.
Is there a trick to this?
You haven't provided an action attribute for your actionSupport component. According to the docs, this will simply cause a page refresh, which may be why you aren't seeing an Ajax request.
Also, you've specified immediate="true". This means that the values you have entered are discarded rather than used to update the bound properties from your controller. Remove this attribute (same as setting it to false) and you should see the second input field displayed when you select the appropriate item from the multi-select picklist.
After more experimenting, I can demonstrate that no action is needed, and that "immediate=true" is not the problem.
The following is a complete example of a VF page that exhibits the behavior I want. "immediate=true" is necessary in order to have the bound variables within the actionregion posted/submitted without causing validation of other fields on the page (which would fail and produce big red error messages if user has not yet completely entered all data).
No action is required, because all I want is to rerender a part of the page.
This page doesn't depend upon any apex code; is uses no controller. When the user chooses "New" for status, a post occurs, and the "Other" field is displayed. When the user then chooses any other status, the Other field disappears. The actionstatus makes clear that this is happening.
However, If I replace Case.Status and CONTAINS(Case.Status, "New" ) with Case.Categories__c and CONTAINS(Case.Categories__c, 'Other'), then no rerendering occurs.
I suspect that this is a bug in the way events are implemented for multipicklists.
<apex:page standardController="Case">
<apex:form>
<apex:pageBlock id="wholePage">
<apex:pageBlockSection id="rerender_target">
<apex:pageBlockSectionItem>
<apex:outputLabel value="Case Status" for="categories"/>
<apex:actionregion immediate="true">
<apex:inputField value="{!Case.Status}"
required="true">
<apex:actionSupport event="onchange"
rerender="rerender_target"
status="updating_other_status"/>
</apex:inputField>
</apex:actionregion>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputPanel rendered="{!CONTAINS(Case.Status,'New')}">
<apex:outputLabel value="Other Categories" for="other_categories"/>
<apex:inputField value="{!Case.Other_Case_Categories__c}"
id="other_categories"/>
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:actionStatus startText="updating..." id="updating_other_status" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
The CONTAINS function only works with picklists.
With multi-picklists you will need to use INCLUDES
<apex:outputPanel rendered="{!INCLUDES(Case.Case_Categories__c,'Other')}">
However, I don't think the formula is the problem, because this also never produces a rerender:
<apex:outputPanel rendered="{!LEN(Case.Case_Categories__c)!=0}">
I think, instead, that multipicklists generate compound html (the two column thingy is not a feature of any html element I am aware of), and that salesforce has not implemented events correctly for the generated code.
Hi bob_buzzard,
Do you mind sharing the custom component code that you have created for multi-select picklist?
I have written my own component, but the functionality doesn't seem to work. as the standard Salesforce multi-select picklist.