I have a VF page where several field's required
attribute is dynamically tied to the value selected on a picklist:
<apex:outputPanel id="idAccountField">
<apex:inputfield value="{!Account__c}" required="{!(dependentPicklist__c == 'Option 1')}" />
</apex:outputPanel>
Since fields' required status needs to change when the dependent picklist is changed, I set the page to rerender all the affected fields whenever there is an 'onChange' DOM event:
<apex:actionRegion>
<apex:inputfield value="{!dependentPicklist__c}">
<apex:actionSupport event="onchange" reRender="idAccountField,idAssetField,idProjectField,idRoleField,idErrorMessage"/>
</apex:inputField>
</apex:actionRegion>
Here's the issue:
dependentPicklist's picklist options are dependent on what is selected on masterPicklist.
In the case where the masterPicklist value is tied to multiple possible dependentPicklist values, then dependentPicklist's value will to revert to '--None--', forcing you to select an available option. This is good, as it triggers the onChange DOM event.
However, in the case where a masterPicklist value is tied to a single dependentPicklist value, then dependentPicklist defaults directly to that value. And although this results in a changed value, the onChange DOM event does not fire.
So am I misunderstanding the nature of the DOM event? How can I ensure that the apex:actionSupport
fires whenever dependentPicklist's value changes, regardless of the mechanism of change?