1

Sorry if this is known, but I could not find it by searching. We were considering switching to MyFaces 2.2 instead of Mojarra. But we see one difference with the facelets templating. We have this:

a common template which has:

<ui:insert name="header">
    <ui:include src="header2.xhtml" >
    </ui:include>
</ui:insert>
<ui:insert name="content">
    <ui:include src="contents.xhtml" />
</ui:insert>
<ui:insert name="footer">
    <ui:include src="footer.xhtml" />
</ui:insert>

In the header, we have:

<h:outputText value="#{pagename}" styleClass="pagetitle" />

The contents is basically blank but each page xhtml file defines the parameter:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    template="common.xhtml">
<ui:param name="pagename" value="My Page" />
</ui:composition>

If we use Mojarra 2.2, the header shows pagename variable. But in MyFaces is does not resolve and it's blank.

Any idea how to have that variable from one ui region be visible in the header using MyFaces?

Thank you

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • Mojarra 2.2.a and Myfaces 2.2.b I assume, a and b being? Tried 2.3 versions? Tried with 2.2 and up namespaces? – Kukeltje May 05 '20 at 20:12
  • oh and check the improved title. Maybe you can improve it even more – Kukeltje May 05 '20 at 20:13
  • More on-topic: I'm not surprised by the behaviour of Mojarra or Myfaces. Initially I'd think that you just pass the param to the template (does it show if you have it in an `` in the template?) and the template does not explicitly pass it down to the includes (Did you try to explicitly pass it on down). So that would be substantiated behaviour. On the other hand, a `ui:param` being implicitly passed down is another way to approach this. Would also be a substantiated behaviour. Specs might be the referee ;-) – Kukeltje May 05 '20 at 20:31
  • I can't go to 2.3 yet, so just on 2.2. It will be shown if put in the common.xhtml template. And yes, just tested it WILL pass down if I do something like: ` ` That does the trick! – atomz4peace May 05 '20 at 20:52
  • I said *try* on 2.3, not to use it in production ;-) And please, explicit version info like requested in my first comment – Kukeltje May 05 '20 at 21:14
  • MyFaces is indeed stricter in scope of ``. Try putting another `` inside the ``. This should theoretically work for MyFaces. – BalusC May 05 '20 at 21:26
  • @BalusC; this works, op confirmed this right befor your post – Kukeltje May 06 '20 at 07:41

0 Answers0