简体   繁体   English

JSF中带有模板的Primefaces的update属性

[英]Primefaces' update attribute with templates in JSF

I have a template made of one header and one body. 我有一个由一个标题和一个主体组成的模板。 In the header there's a Primefaces ajax component that has to update portions of my body. 标头中有一个Primefaces ajax组件,该组件必须更新我的身体的各个部分。 The problem is that pages which implement the body template have panels and other components with different ids and the update attribute of my header's component expects a list of ids. 问题是实现主体模板的页面具有面板和其他具有不同ID的组件,而我标头组件的update属性需要一个ID列表。

What I need? 我需要的? I need to let my pages set the header's component's update attribute. 我需要让我的页面设置标题的组件的update属性。 So, anywhere in my application flow, the header component will update the correct portions of the specifically page. 因此,在我的应用程序流程中的任何地方,标头组件都会更新特定页面的正确部分。

Is that possible? 那可能吗?

Running on PrimeFaces 3.5, Mojarra 2.1.13, JDK 1.6.x. 在PrimeFaces 3.5,Mojarra 2.1.13,JDK 1.6.x上运行。 Thanks! 谢谢!

If I undertand correctly, here is the way you can do it : 如果我正确理解,可以采用以下方法:

Your main template should looks like this (say index.xhtml ) : 您的主模板应如下所示(例如index.xhtml ):

<h:head>

</h:head>
<h:body>
    <h:form>
        <p:commandButton update="#{regions}" value="Update" />
    </h:form>

    <ui:insert name="page" />
</h:body>

And each or your page should looks like this (say page.xhtml ) : 并且每个页面或您的页面应如下所示(例如page.xhtml ):

<ui:composition template="index.xhtml">
    <ui:param name="regions" value=":panel1" />

    <ui:define name="page">
        <p:panel id="panel1">
            <h:outputText value="#{bean.date}" />
        </p:panel>
        <p:panel id="panel2">
            <h:outputText value="#{bean.date}" />
        </p:panel>
    </ui:define>
</ui:composition>

In this example all you need is to change the ui:param value according of the list of components you want to update. 在此示例中,您所需要做的就是根据要更新的组件列表更改ui:param值。 Pay attention to form IDs and prependId="false" . 注意表单ID和prependId="false"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM