Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在同一页面的支持bean中检索ui:param的值_Java_Jsf 2_Facelets_Composite Component - Fatal编程技术网

Java 如何在同一页面的支持bean中检索ui:param的值

Java 如何在同一页面的支持bean中检索ui:param的值,java,jsf-2,facelets,composite-component,Java,Jsf 2,Facelets,Composite Component,我想在我的支持bean中检索ui:param的值,但不是在从一页导航到另一页时,而是在同一页中检索它。我尝试了: FaceletContext faceletContext = (FaceletContext) FacesContext.getCurrentInstance().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY); String formId = (String) faceletContext.getAttribute(

我想在我的支持bean中检索ui:param的值,但不是在从一页导航到另一页时,而是在同一页中检索它。
我尝试了:

FaceletContext faceletContext = (FaceletContext) FacesContext.getCurrentInstance().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
String formId = (String) faceletContext.getAttribute("formId");

它返回空值,我也尝试过:

String param = FacesContext.getCurrentInstance().getExternalContext()
            .getRequestParameterMap().get(name);

它还返回null
我尝试在preRenderView和postValidate事件中获取这些有效值,并以两种方式返回null
不要忘记,我想获取我所在页面的ui:param的值。我想问题与我同样面临的问题非常相似。 请允许我解释一下这个问题

当有两个“ui:include”包装在“p:dialog”下时,我遇到了这个问题。。 像这样的

<p:dialog header="Customer Selection Criteria" widgetVar="customerSelectionDialog" width="1200" position="center" appendToBody="true">
        <h:form id="customerForm">
            <p:outputPanel id="customerSelection">
                <ui:include src="../INTERNAL/8500.xhtml">
                    <ui:param name="showCidSelect" value="1" /> 
                    <ui:param name="targetObject" value="#{customerDetailsInquiry.cf8444.cg1014.cg1014cidnumb}" />
                </ui:include>
                <p:commandButton rendered="false" value="#{COMMON.COMMON_SELECTBUTTON}" action="#{customerDetailsInquiry.tchelp.handleReturnFromCustomerSelectionCriteria}" oncomplete="customerSelectionDialog.hide();" update=":mainForm:cf8444icg1014c1002" >
                    <f:setPropertyActionListener value="#{customerSearchEngine}" target="#{flash.customerSearchEngine}"/>
                </p:commandButton>
            </p:outputPanel>
        </h:form>
    </p:dialog>
    <p:dialog closeOnEscape="true" modal="true" appendToBody="false" header="Entity Stack" widgetVar="entityStackDialog" width="400" >
        <h:form id="entityForm">
            <ui:include src="../INTERNAL/StackedEntity.xhtml">
                <ui:param name="displayCaption" value="CID Numbers" />

                <ui:param name="department" value="8" /> 
                <ui:param name="stackedObject" value="#{customerDetailsInquiry.cf8444.cg1014.cg1014cidnumb}" />
            </ui:include>

        </h:form>
    </p:dialog>

现在,当我尝试启动8500.xhtml时,我的showCidSelect参数值总是返回“null”。 如果我按如下方式替换代码,则效果很好

<p:dialog header="Customer Selection Criteria" widgetVar="customerSelectionDialog" width="1200" position="center" appendToBody="true">
        <h:form id="customerForm">
            <p:outputPanel id="customerSelection">
                <ui:include src="../INTERNAL/8500.xhtml">
                    <ui:param name="showCidSelect" value="1" /> 
                    <ui:param name="targetObject" value="#{customerDetailsInquiry.cf8444.cg1014.cg1014cidnumb}" />
                </ui:include>
                <p:commandButton rendered="false" value="#{COMMON.COMMON_SELECTBUTTON}" action="#{customerDetailsInquiry.tchelp.handleReturnFromCustomerSelectionCriteria}" oncomplete="customerSelectionDialog.hide();" update=":mainForm:cf8444icg1014c1002" >
                    <f:setPropertyActionListener value="#{customerSearchEngine}" target="#{flash.customerSearchEngine}"/>
                </p:commandButton>
            </p:outputPanel>
        </h:form>
    </p:dialog>
    <p:dialog closeOnEscape="true" modal="true" appendToBody="false" header="Entity Stack" widgetVar="entityStackDialog" width="400" >
        <h:form id="entityForm">
            <ui:include src="../INTERNAL/StackedEntity.xhtml">
                <ui:param name="displayCaption" value="CID Numbers" />
                <ui:param name="showCidSelect" value="1" />
                <ui:param name="department" value="8" /> 
                <ui:param name="stackedObject" value="#{customerDetailsInquiry.cf8444.cg1014.cg1014cidnumb}" />
            </ui:include>

        </h:form>
    </p:dialog>

我必须显式地将showCidSelect传递给“ui:include”以使其工作

这可能也是您面临的问题吗?

发布一些UI的示例代码。

尝试使用f:param代替UI:param。我尝试了它,但也返回了null。当我遇到同样的问题时,我遇到了这个问题。对我来说,错误信息有点误导。实际上,不是
对象引用为
null
,而是我使用的接口上没有声明该对象上的方法。我的建议是在UI参数中“value”引用的对象上设置断点,并检查它是否真的为
null