Reputation: 4801
I got this error:
execute="#{localeManager.changeLocale}": Property 'changeLocale' not found on type xyz.com.i18n.LocaleManager
where LocaleManager is:
@ManagedBean
@ViewScoped
public class LocaleManager implements Serializable
{
// other codes here
public static void changeLocale(AjaxBehaviorEvent event) {
newLocale = (Locale) new Locale((String) event.toString());
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("selectedLocale", newLocale);
}
}
and I'm calling the bean's method here:
<h:selectOneMenu id="selectLang" immediate="true" value="#{langListing.language}">
<f:ajax event="change" execute="#{localeManager.changeLocale}" />
<f:selectItems value="#{langListing.languages}" />
</h:selectOneMenu>
I'm learning AJAX by experimenting with this code. But I don't understand how Ajax evaluates bean's method. Is this a straightforward issue to resolve?
Upvotes: 2
Views: 1391
Reputation: 1108762
As per the <f:ajax>
tag documentation the execute
attribute should refer to a collection of client IDs which are to be processed at the server side. This should not refer to some bean action method. The exception is coming because it's expecting a getter method which returns a collection of client IDs.
You want to use the listener
attribute instead.
<f:ajax listener="#{localeManager.changeLocale}" />
Note that the default event for h:selectOneMenu
is already valueChange
. You can just omit it.
Upvotes: 1