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
Jsf p:outputPanel不呈现页面节_Jsf_Jsf 2_Primefaces - Fatal编程技术网

Jsf p:outputPanel不呈现页面节

Jsf p:outputPanel不呈现页面节,jsf,jsf-2,primefaces,Jsf,Jsf 2,Primefaces,我有两个p:ouputPanel,它们具有rendered属性。当基础getter/setter的值更改时,应该呈现它们。但是,基础值的变化顺序是正确的。第一个面板消失,但第二个面板不显示。即使不是在HTML代码中 我的两个小组: <p:outputPanel id="PanelParent"> <h:form> <p:outputPanel id="PanelForm" rendered="#{PageService.isVis

我有两个
p:ouputPanel
,它们具有
rendered
属性。当基础
getter/setter
的值更改时,应该呈现它们。但是,基础值的变化顺序是正确的。第一个面板消失,但第二个面板不显示。即使不是在HTML代码中

我的两个小组:

    <p:outputPanel id="PanelParent">

     <h:form>
        <p:outputPanel id="PanelForm" rendered="#{PageService.isVisibilityForm()}">

        <h:commandButton value="Button"
                                            action="#{PageService.persist}"
                                            styleClass="btn btn-primary opal_btn submit_form_new" />
     </h:form>                      
        </p:outputPanel>

        <p:outputPanel id="PanelMessage" rendered="#{PageService.isVisibilityMessage()}">

        //Message

        </p:outputPanel>

    </p:outputPanel>

//信息
谢谢你的回答

-更新-

在代码中,我引用了persist方法,在这个方法中,我更改了每个部分的可见性的getter和setter

-UPDATE1-

好的,这是我的代码:

            <p:outputPanel id="parentPanel">
                <p:outputPanel id="PanelForm"
                    rendered="#{PageService.isVisibilityForm()}">
                    <div>
                        <div>
                            <h:form class="homepage_invitee_form" action="" method="POST">

                                <p:messages id="messages" showDetail="false" autoUpdate="true"
                                    closable="true" />

                                <h:inputText required="true"
                                    value="#{PageService.instance.name}"
                                    name="name" placeholder="Last Name"
                                    styleClass="lastname_new" id="lastname_new"
                                    type="text placeholder" />

                                <h:commandButton value="Press"
                                    action="#{PageService.persist()}"/>

                                    <f:ajax render="" />
                                </h:commandButton>

                            </h:form>
                        </div>

                    </div>
                </p:outputPanel>

                <p:outputPanel id="PanelThank"
                    rendered="#{PageService.isVisibilityThank()}">
                    <div>
                        Message
                    </div>
                </p:outputPanel>
            </p:outputPanel>

消息

我真的看不出哪里失败了;(

呈现的
属性。您的问题是无法更新不在树中的组件,因为您根本没有该组件:

<p:outputPanel id="PanelForm" rendered="#{PageService.isVisibilityForm()}">
    //my Form
<p:outputPanel>

<!--Fails if not PageService.isVisibilityForm(), because you don't have the component itself in the tree! So can't find it-->
<p:ajax update="PanelForm"/>

//我的表格
最好将内容包装在另一个始终呈现的容器中,并更新它,而不是另一个容器:

<h:panelGroup id="updatablePanel">
    <p:outputPanel rendered="#{PageService.isVisibilityForm()}">
        //my Form
    <p:outputPanel>
</h:panelGroup>

<p:ajax update="updatablePanel"/>

//我的表格

呈现的
属性。您的问题是无法更新不在树中的组件,因为您根本没有该组件:

<p:outputPanel id="PanelForm" rendered="#{PageService.isVisibilityForm()}">
    //my Form
<p:outputPanel>

<!--Fails if not PageService.isVisibilityForm(), because you don't have the component itself in the tree! So can't find it-->
<p:ajax update="PanelForm"/>

//我的表格
最好将内容包装在另一个始终呈现的容器中,并更新它,而不是另一个容器:

<h:panelGroup id="updatablePanel">
    <p:outputPanel rendered="#{PageService.isVisibilityForm()}">
        //my Form
    <p:outputPanel>
</h:panelGroup>

<p:ajax update="updatablePanel"/>

//我的表格

就像Xtreme Biker说的那样,
呈现
属性将呈现DOM中已经存在的元素。在您的例子中,
呈现
属性的计算结果为
,因此它不在DOM中。因此,
无法呈现它。您需要指向alw可见的,改变

<f:ajax render="" />


但更重要的是改变

<p:outputPanel id="PanelThank" rendered="#{PageService.isVisibilityThank()}">
    <div>
        Message
    </div>
</p:outputPanel>

消息


消息

考虑重构你的代码。例如,
中的
操作和
方法是不需要的。

就像Xtreme Biker说的
呈现
属性将呈现DOM中已经存在的元素。在你的例子中,
呈现
属性的计算结果是
false
因此它不在DOM中。因此,
无法呈现它。您需要指向始终可见的内容。更改

<f:ajax render="" />


但更重要的是改变

<p:outputPanel id="PanelThank" rendered="#{PageService.isVisibilityThank()}">
    <div>
        Message
    </div>
</p:outputPanel>

消息


消息


还可以考虑重构代码。例如,
中的
操作
方法
是不需要的。

对不起,我想我还不够清楚。条件是如何评估的?您是否单击了按钮?一旦评估了条件,您将如何更新页面我根据一些假设发布了答案。您应该重写代码(正确关闭标记)并且发布你正在做什么来更新你的客户端部分。好的,我可以在我这边复制它。给我一点时间。
visibilityForm
按照
isVisibilityForm
的顺序。getter不需要
get
/
is
prefixok,Maximus你想要答案还是我也应该重构你的代码?对不起,我想我不是不够清楚。条件是如何评估的?您是否单击了按钮?评估条件后,您如何更新页面?我根据一些假设发布了答案。您应该重写代码(正确关闭标记)并且发布你正在做什么来更新你的客户端。好的,我可以在我这端复制它。给我一点时间。
visibilityForm
按照
isVisibilityForm
的顺序。getter不需要
get
/
is
preffix确定,Maximus你想要答案还是我也应该重构你的代码?谢谢你的答案!我正如您在回答中解释的那样,但是,我得到的
事件属性无法确定:null
我必须在哪个容器中提供
p:ajax
?您使用哪个组件更新视图?您提到它是您的按钮之一。您必须将ajax标记包装在组件中。您可以使用
f:ajax>也是。看看。我想让
面板窗体消失,让
面板消息出现。因此,我更新了这两个组件。我必须在这两个面板中的每个面板中都放一个
ajax
组件吗?我真的很感谢你的回答!!!不客气,尝试一下按钮中的
。这将使重新呈现整个表单。顺便说一句,请再次修复代码。我不认为ajax是个问题。没错,它更有效,但由于他提交了整个表单,它应该仍然可以工作,而且它在我这边(至少给出了代码).Thx谢谢你的回答!我按照你在回答中解释的那样做了,但是,我得到的
事件属性无法确定:null
我必须在哪个容器中提供
p:ajax
?你使用哪个组件更新你的视图?你提到它是你的一个按钮。你必须在组件中包装ajax标记。Y你也可以使用
f:ajax
。看看这个。我想让它消失