2011-02-16 95 views
4

我需要获取在我的Facelets文件中定义的隐藏变量的值,以处理我的bean中的事务。我在流程操作方法中使用了下面一行来获取隐藏的输入组件。但我得到null。我怎样才能得到指定的隐藏输入值?JSF中的隐藏变量

豆子:

UIInput classNameComponent = (UIInput) event.getComponent().findComponent("className"); 

的观点:

<ui:composition template="/templates/content.xhtml"> 
... 
    <h:form id="classForm"> 
    ... 
     <o:dataTable id="classTable"> 
     ... 
      <f:facet name="import"> 
        <h:inputHidden id="className" value="com.LoadClass" /> 
      </f:facet> 
      ... 
     </o:dataTable> 
    ... 
    </h:form> 
... 
</ui:composition> 
+0

即使您自己找到答案,也有更好的方法来实现这一点。我只需要首先知道您是使用JSF 1.x还是2.x(并且您在未来的JSF问题中应该提到这一点)。 – BalusC 2011-02-16 12:38:22

回答

2

我找到了答案!我已经通过下面提到的方法得到了它。

className = (String) FacesContext.getCurrentInstance().getExternalContext() 
     .getRequestParameterMap().get("classForm:className");