【问题标题】:Hidden Variables in JSFJSF 中的隐藏变量
【发布时间】:2011-02-16 05:47:18
【问题描述】:

我需要获取在我的 Facelets 文件中定义的隐藏变量的值,以处理我的 bean 中的事务。我在流程操作方法中使用以下行来获取隐藏的输入组件。但我收到null。如何获取指定的隐藏输入值?

豆子:

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>

【问题讨论】:

  • 即使您自己找到了答案,也有更好的方法来实现这一点。我只需要首先知道您使用的是 JSF 1.x 还是 2.x(您应该在以后的 JSF 问题中提到这一点)。

标签: java jsf xhtml


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2015-09-27
    • 2012-11-05
    • 1970-01-01
    • 1970-01-01
    • 2011-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多