3
votes

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. 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.

What I need? I need to let my pages set the header's component's update attribute. 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. Thanks!

1

1 Answers

2
votes

If I undertand correctly, here is the way you can do it :

Your main template should looks like this (say 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) :

<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. Pay attention to form IDs and prependId="false".