I ran into what I thought was a bug yesterday with the actionSupport Visualforce component but it turned out to be the intended functionality, according to Salesforce.com. I'm not sure if I agree as I can envision a number of use cases where it prohibits functionality.
The actionSupport component adds AJAX support to another component, allowing the component to be refreshed asynchronously by the server when a particular event occurs, such as a button click or mouseover.
So let's say we build the Visualforce page above. The page allows us to choose a contact from a picklist and the form fields populate with the first name, last name and email address from the contact. There are validation rules on all three fields that requires us to enter data.
Here is a code snippet for the Visualforce page with the actionSupport component. When the user changes the value of the picklist, the showContact method is fired and the fields are refreshed with the corresponding data.
So this works great with one exception. Suppose you have one contact that does not have an email address (in reality the email address should have a value as it's required, but work with me here). When that contact is loaded into the form with a blank email address and the user selects a different contact from the picklist, the validation rule will fire prompting you to enter an email address to continue. Fortunately, Salesforce.com has provided an attribute on the actionSupport component called immediate to allow you to bypass the validation rules:
Immediate - A Boolean value that specifies whether the action associated with this component should happen immediately, without processing any validation rules associated with the fields on the page. If set to true, the action happens immediately and validation rules are skipped. If not specified, this value defaults to false.
So now we change our Visualforce page to skip the validation rules when the user changes the picklist value:
So now here's the real problem. When using the immediate attribute not only does actionSupport skip the validation rules but it also skips all setter methods. Our code never receives the Id that our user chose so our SOQL query will never execute correctly.
Andrew Waite, Product Manager - salesforce.com, in this forum post states that this is the intended functionality. I ran into two situations yesterday where I needed the actionSupport to skip validation rules and fire setters to function correctly. I think this component should be modified to fire setters.
Here's the Idea so please vote early and often.