Java jsf:将参数传递给支持bean中的方法
我需要将#{bean.userProfile}这样的参数传递给支持bean中的clear(userProfile)这样的方法Java jsf:将参数传递给支持bean中的方法,java,jsf,richfaces,Java,Jsf,Richfaces,我需要将#{bean.userProfile}这样的参数传递给支持bean中的clear(userProfile)这样的方法 <a4j:commandButton value="Cancel" onclick="#{rich:component('id_up')}.hide()" execute="@this" type="reset" action="#{profilesBean.clear()}" render="id_panel"> 我需要通过“selectedProfi
<a4j:commandButton value="Cancel" onclick="#{rich:component('id_up')}.hide()" execute="@this" type="reset" action="#{profilesBean.clear()}" render="id_panel">
我需要通过“selectedProfile”发送所有userProfile属性 有几种方法可以将参数从jsf页面传递到backingBean,我通常使用这种方法:
<h:commandButton action="#{profilesBean.clear}" >
<f:setPropertyActionListener target="#{profilesBean.selectedProfile}" value="#{profilesBean.userProfile}" />
</h:commandButton>
你可以在我喜欢的中找到其他方法
<h:commandButton action="#{profilesBean.clear}">
<f:param name="selectedProfile" value="selectedProfile" />
</h:commandButton>
和腐蚀豆
public String clear() {
Map<String,String> params =
FacesContext.getExternalContext().getRequestParameterMap();
String action = params.get("selectedProfile");
//...
}
公共字符串清除(){
映射参数=
FacesContext.getExternalContext().getRequestParameterMap();
String action=params.get(“selectedProfile”);
//...
}
如果使用EL2.2,则可以使用与预期非常相似的语法(第二个应删除):
action=“#{profilesBean.clear(profilesBean.selectedProfile)}”实际上应该“正常工作”,假设它是JSF 2或更高版本。但是如果它是同一个bean(profilesBean),那么为什么需要将其作为参数发送呢?
public String clear() {
Map<String,String> params =
FacesContext.getExternalContext().getRequestParameterMap();
String action = params.get("selectedProfile");
//...
}
action="#{profilesBean.clear(profilesBean.selectedProfile)}"