JSF访问bean类中的html元素值
我有一个JSF应用程序,我有一个combobox。
我正在获取bean类中该combobox的选定值,如:
public void setSelectedTransformationRule(String transformationRule) throws GeneralException { String collectorType = (String) getRequestParam().get("editForm:collectorType"); }
我成功地这样做了。 我通过combobox的ajax onchage事件调用此方法。
但是,如果我尝试在不同的方法中获得相同的combobox值,我将获得null值。
public void handleCollectorTypeChange() throws GeneralException { String collectorType = (String) getRequestParam().get("editForm:collectorType"); }
任何帮助!
尝试将属性进程和partialSubmit放入ajax调用中,并使用您需要的值进行处理,如下所示:
在此过程中,您可以使用更新的值来处理您需要处理的所有ID(就像您在屏幕上看到的那样)。
因为Process Events
在Update Model Values
之前发生,所以您可以从UIViewRoot
检索组件中的值,如下所示:
HtmlSelectOneMenu collectorTypeSelectMenu = (HtmlSelectOneMenu) FacesContext.getCurrentInstance().getViewRoot().findComponent("editForm:collectorType"); String collectorType = (String) collectorTypeSelectMenu.getValue();