Hi All,

I have an issue with the view parameters in combination with templating.

in file *templates/template.xhtml
*
*<html xmlns="http://www.w3.org/1999/xhtml"; xmlns:h="
http://java.sun.com/jsf/html";
      xmlns:f="http://java.sun.com/jsf/core";
      xmlns:ui="http://java.sun.com/jsf/facelets";>

<f:metadata>
    <f:viewParam name="parameterValue" value="#{helloBean.test}"
id="paramTemplate" />
</f:metadata>

<h:head>
....
*

in file *test.xhtml

**<html xmlns="http://www.w3.org/1999/xhtml"; xmlns:h="
http://java.sun.com/jsf/html";
      xmlns:f="http://java.sun.com/jsf/core";
      xmlns:ui="http://java.sun.com/jsf/facelets";>

<body>
<ui:composition template="/templates/template.xhtml">

    <ui:define name="title">ViewParameter issue</ui:define>

    <ui:define name="content">
            Parameter value #{param.parameterValue} <br/>
            Backing bean property #{helloBean.test} <br/>
....
*
When I call the page with the URL test.jsf?parameterValue=Rudy, only the
first line is correct, the el #{helloBean.test} returns null.

Without templating, the correct behaviour is shown.

I was able to trace it back to the class
org.apache.myfaces.view.facelets.compiler.SAXCompiler.ViewMetadataHandler
which only takes into account the <f:metadata> tags in the file. (called
from the RestoreViewExecutor when the view meta data is generated in case
of a non-postback (viewRoot = metadata.createMetadataView(facesContext);  )
This handler ignores the <ui:composition> and thus missing the definition
in the template.

You can work around it by specifying the <f:metadata> within a <ui:define>
and put it in the template at the correct place (so that the parent of
<f:metadata> is the ViewRoot)

I have the use case that I have a lot of pages where a viewParameter should
be present and I don't like to repeat it on every view (in case things
changes)

Is this issue to specific for my situation or should I create a Jira Issue
for it?

Regards
Rudy

-- 
Rudy De Busscher
http://www.c4j.be

Reply via email to