Reputation: 603
I need to pass an argument like #{bean.userProfile} to a method like clear(UserProfile profile) in the backing bean.
<a4j:commandButton value="Cancel" onclick="#{rich:component('id_up')}.hide()" execute="@this" type="reset" action="#{profilesBean.clear()}" render="id_panel">
I'm looking for the syntax for writing something like this in the action:
action="#{profilesBean.clear(#profilesBean.selectedProfile)}"
I need to send all userProfile attributes via "selectedProfile".
Upvotes: 0
Views: 4015
Reputation: 3728
If you use EL2.2 then you can use very similar syntax as you expected (second # should be removed):
action="#{profilesBean.clear(profilesBean.selectedProfile)}"
Upvotes: 1
Reputation: 11896
I prefer
<h:commandButton action="#{profilesBean.clear}">
<f:param name="selectedProfile" value="selectedProfile" />
</h:commandButton>
and corrosponding bean
public String clear() {
Map<String,String> params =
FacesContext.getExternalContext().getRequestParameterMap();
String action = params.get("selectedProfile");
//...
}
Upvotes: 0
Reputation: 81
there are several ways to pass parameter from jsf page to backingBean, i usually use this way:
<h:commandButton action="#{profilesBean.clear}" >
<f:setPropertyActionListener target="#{profilesBean.selectedProfile}" value="#{profilesBean.userProfile}" />
</h:commandButton>
you can find the other ways in mkyong site
Upvotes: 0