【发布时间】:2011-04-26 11:04:09
【问题描述】:
我正在使用 JSF 数据表。表中的一列是命令按钮。
单击此按钮时,我需要使用表达式语言传递一些参数(例如所选行的值)。这些参数需要传递给 JSF 托管 bean,后者可以对其执行方法。
我使用了以下 sn-p 代码,但我在 JSF bean 上获得的值始终为空。
<h:column>
<f:facet name="header">
<h:outputText value="Follow"/>
</f:facet>
<h:commandButton id="FollwDoc" action="#{usermanager.followDoctor}" value="Follow" />
<h:inputHidden id="id1" value="#{doc.doctorid}" />
</h:column>
豆方法:
public void followDoctor() {
FacesContext context = FacesContext.getCurrentInstance();
Map requestMap = context.getExternalContext().getRequestParameterMap();
String value = (String)requestMap.get("id1");
System.out.println("Doctor Added to patient List"+ value);
}
如何使用命令按钮将值传递给 JSF 托管 bean?
【问题讨论】: