I'm extracting part of a Visualforce page into a component, however there's one piece of functionality that doesn't come across. Here's a simplified apex snippet:

    <apex:actionFunction action="{!zipChanged}" name="zipUpdate" rerender="state" />
    <apex:inputField value="{!thing.ZipCode__c}" onchange="zipUpdate();" />
    <apex:inputText id="state" value="{!thing.State__c}" required="true" />

This works fine in the Visualforce page, but not the component. The onchange fires, and there's a postback in the logs, but I don't see any debug statements even when I add some to the getters/setters that are being called in the logs (so I assume that's the view state or whatever being processed). Needless to say, zipChanged is not called.

Why is zipChanged not being called?

  • In case somebody thinks to ask: Yes, there is a surrounding form tag. – ricksmt Apr 3 '15 at 15:39

Your input Text state is required field & also within actionRegion Hence your method zipChanged will be called only when state is populated & zip is changed.

| improve this answer | |
  • 1) You ignore that I said this works on the Visualforce page, 2) State happens to be present in my case, and 3) I've already tried with state outside the actionRegion: same result. – ricksmt Apr 3 '15 at 15:39

We have the same problems. Actionfunctions and Actionregions are not working properly within components.

Ugly workaround:

Create an actionfunction (in a different form to be sure) that has explicit apex:params and then call it with the param value set explicitly

<apex:actionFunction action="{!zipChanged}" name="zipUpdate" rerender="state" />
    <apex:param value="123" assignTo="{!thing.ZipCode__c}" id="zip" name="zip" />
<apex:inputField value="{!thing.ZipCode__c}" onchange="zipUpdate(this.value);" />
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.