Hi Leonardo,

Didn't look into the javadoc of the spec, only in the PDF. My fault, thx
for looking it up.

It is clearly not an option to change it, spec says it can't be in a
template.

I also tried something extraordinary but it works (after I looked more in
depth to the process of extracting the metaData)
You are allowed to put the <f:metadata> OUTSIDE of the <ui:composition>
tag.  Normally everything outside that tags is ignored, but <f:metadata> is
something special.

so file *test.xhtml* becomes*

**<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>
**<f:metadata>
    <f:viewParam name="parameterValue" value="#{helloBean.test}"
id="paramPage" />
</f:metadata>*
* <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/>
....
*
Regards
Rudy

On 12 January 2012 16:28, Leonardo Uribe <lu4...@gmail.com> wrote:

> Hi
>
> Look the javadoc of f:metadata:
>
> "... Declare the metadata facet for this view. This must be a child of
> the <f:view>. This tag must reside within the top level XHTML file for
> the given viewId, or in a template client, but not in a template. ..."
>
> That behavior is declared on the spec, and the reason behind that is
> the compiler parse xhtml files in a different way when metadata is
> retrieved.
>
> regards,
>
> Leonardo Uribe
>
> 2012/1/12 Rudy De Busscher <rdebussc...@gmail.com>:
> > 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
> >
>



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

Reply via email to