0

I have a problem when adding view parameters to a <h:link includeViewParams="true" /> - they are not added to the rendered link. I am using Mojarra 2.3.9.

  • Template /WEB-INF/templates/main.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:c="http://java.sun.com/jsp/jstl/core">

<h:head>
  <!-- Some headers -->
</h:head>

<h:body>
    <f:view>
        <ui:insert name="metaContent" />
        <div class="container-fluid" id="mainContent">
            <ui:insert name="mainContent" />
        </div>
    </f:view>
</h:body>
</html> 
  • Template being used on page test.xhtml
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:o="http://omnifaces.org/ui"
    template="/WEB-INF/templates/main.xhtml">

    <ui:define name="metaContent">
        <f:metadata>
            <f:viewParam name="id" value="#{myBean.obj}" required="true">
                <f:validator validatorId="myIdVvalidator" />
                <f:converter converterId="myConverter" />
            </f:viewParam>
        </f:metadata>
    </ui:define>

    <ui:define name="mainContent">
        <!-- Simply reference current page -->
        <h:link outcome="test.xhtml" includeViewParams="true">
          My link
        </h:link>
    </ui:define>
</ui:composition>

Update

If I remove the attribute value of f:viewParam as well as the f:converterand f:validator child elements, the link is rendered as expected. Why can this cause a problem? The Bean myBean is @RequestScoped

Selaron
  • 6,105
  • 4
  • 31
  • 39
MichaelRS
  • 51
  • 3
  • Does it work when not using `ui:include`? – Kukeltje Dec 11 '19 at 09:37
  • @Kukeltje It seemed to be a weird problem with Eclipse/Tomcat. Finally I removed the module, deleted the server in eclipse, restarted everything and finally it works now as expected... – MichaelRS Dec 11 '19 at 10:12

0 Answers0