1
votes

I'm not able to retain values across nested ui:include passed by ui:param

So say, page1.xhtml contains

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="../template.xhtml" 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" xmlns:p="http://primefaces.org/ui">
  <ui:param name="paramGlobal" value="123" />
  <ui:define name="content">
    <h:form id="frm1">
      <f:view>
        <ui:include src="page2.xhtml">
          <ui:param name="paramInclude" value="abc"></ui:param>
        </ui:include>
      </f:view>
    </h:form>
  </ui:define>
</ui:composition>

and page2.xhtml contains

<?xml version="1.0" encoding="UTF-8"?>
<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" xmlns:p="http://primefaces.org/ui">
  <p:panelGrid columns="2">
    <p:outputLabel value="Page 2"></p:outputLabel>
    <p:outputLabel value="Value"></p:outputLabel>
    <p:outputLabel value="Global"></p:outputLabel>
    <p:inputText value="#{paramGlobal}"></p:inputText>
    <p:outputLabel value="Param Include"></p:outputLabel>
    <p:inputText value="#{paramInclude}"></p:inputText>
    <ui:include src="page3.xhtml">
      <ui:param name="paramNestedInclude" value="def"></ui:param>
    </ui:include>
  </p:panelGrid>
</ui:composition>

and finally page3.xhtml contains

<?xml version="1.0" encoding="UTF-8"?>
<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" xmlns:p="http://primefaces.org/ui">
  <p:outputLabel value="Page 3"></p:outputLabel>
  <p:outputLabel value="Value"></p:outputLabel>
  <p:outputLabel value="Global"></p:outputLabel>
  <p:inputText value="#{paramGlobal}"></p:inputText>
  <p:outputLabel value="Param Include"></p:outputLabel>
  <p:inputText value="#{paramInclude}"></p:inputText>
  <p:outputLabel value="Param Nested Include"></p:outputLabel>
  <p:inputText value="#{paramNestedInclude}"></p:inputText>
</ui:composition>

The output I get is like this:

Page 2 Value

Global: [blank]

Param Include: abc

Page 3: Value

Global: [blank]

Param Include: [blank]

Param Nested Include: def

I'm not able to figure out why ui:param is not being passed in the included pages.

1

1 Answers

1
votes

Got the issue.

The way ui:param, ui:include and ui:composition work have been changed in MyFaces JSF2.2.

The issue can be solved setting the following param in web.xml

  <context-param>
    <param-name>org.apache.myfaces.STRICT_JSF_2_FACELETS_COMPATIBILITY</param-name>
    <param-value>true</param-value>
  </context-param>

This will make these components behave as earlier.