You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Marcus Büttner <bu...@gmail.com> on 2010/07/13 14:37:06 UTC

PreRenderView Event with post navigation

Hi,

is there a possiblity to trigger PreRenderView event when I navigate via
action to another page?

small example:
I'm on page1.xhtml an there's a button:

<h:commandButton action="page2"/>

page2.xhtml includes:

<f:metadata>
    <f:event type="preRenderView"/>
</f:metadata>

When I use the button then page2 is shown but the PreRenderView event is not
triggerd. The metadata section is only processed in restore view phase. So
the event is triggerd with method GET or with POST without switching page.
Is it possible to trigger this event when I navigate via action?

Thx, regards Marcus

Re: PreRenderView Event with post navigation

Posted by Marcus Büttner <bu...@gmail.com>.
Hi Jan-Kees,

yes, f:metadata is in the top level xhtml. and it works as expected.
It is just processed in restore view phase, which makes sence to trigger the
complete jsf lifecycle if some view parameters exists.

I didn't have the problem that f:metadata does not work correctly but rather
that I need the preRenderView event when I render a new view after post
actions.

Michael's solution works for me.

Thanks for your help.
Marcus



2010/7/13 Jan-Kees van Andel <ja...@gmail.com>

> Hi Marcus,
>
> According to the JSF 2.0 spec, paragraph 10.4.1.3:
> "This tag must reside within the top level XHTML file for the given viewId,
> not in a template."
>
> Is this true in your case?
>
> I've seen <f:metadata> work in the past...
>
> Regards,
> Jan-Kees
>
>
> 2010/7/13 Michael Kurz <mi...@gmx.at>
>
> > Why do you need to put f:event into f:metadata? If you put it outside
> this
> > works like a charm. I didn't look into the details but I think f:metadata
> is
> > not processed for all requests.
> >
> > As you want to register this listener to the view root it should be a
> child
> > of f:view (or at least a "top level" tag if you don't use f:view).
> >
> > regards
> > Michael
> >
> > Am 13.07.2010 14:37, schrieb Marcus Büttner:
> >
> >  Hi,
> >>
> >> is there a possiblity to trigger PreRenderView event when I navigate via
> >> action to another page?
> >>
> >> small example:
> >> I'm on page1.xhtml an there's a button:
> >>
> >> <h:commandButton action="page2"/>
> >>
> >> page2.xhtml includes:
> >>
> >> <f:metadata>
> >>     <f:event type="preRenderView"/>
> >> </f:metadata>
> >>
> >> When I use the button then page2 is shown but the PreRenderView event is
> >> not
> >> triggerd. The metadata section is only processed in restore view phase.
> So
> >> the event is triggerd with method GET or with POST without switching
> page.
> >> Is it possible to trigger this event when I navigate via action?
> >>
> >> Thx, regards Marcus
> >>
> >>
>

Re: PreRenderView Event with post navigation

Posted by Jan-Kees van Andel <ja...@gmail.com>.
Hi Marcus,

According to the JSF 2.0 spec, paragraph 10.4.1.3:
"This tag must reside within the top level XHTML file for the given viewId,
not in a template."

Is this true in your case?

I've seen <f:metadata> work in the past...

Regards,
Jan-Kees


2010/7/13 Michael Kurz <mi...@gmx.at>

> Why do you need to put f:event into f:metadata? If you put it outside this
> works like a charm. I didn't look into the details but I think f:metadata is
> not processed for all requests.
>
> As you want to register this listener to the view root it should be a child
> of f:view (or at least a "top level" tag if you don't use f:view).
>
> regards
> Michael
>
> Am 13.07.2010 14:37, schrieb Marcus Büttner:
>
>  Hi,
>>
>> is there a possiblity to trigger PreRenderView event when I navigate via
>> action to another page?
>>
>> small example:
>> I'm on page1.xhtml an there's a button:
>>
>> <h:commandButton action="page2"/>
>>
>> page2.xhtml includes:
>>
>> <f:metadata>
>>     <f:event type="preRenderView"/>
>> </f:metadata>
>>
>> When I use the button then page2 is shown but the PreRenderView event is
>> not
>> triggerd. The metadata section is only processed in restore view phase. So
>> the event is triggerd with method GET or with POST without switching page.
>> Is it possible to trigger this event when I navigate via action?
>>
>> Thx, regards Marcus
>>
>>

Re: PreRenderView Event with post navigation

Posted by Marcus Büttner <bu...@gmail.com>.
Hi Michael,

thanks for your response. Ok, it makes sence and it works!

Thanks
Marcus



2010/7/13 Michael Kurz <mi...@gmx.at>

> Why do you need to put f:event into f:metadata? If you put it outside this
> works like a charm. I didn't look into the details but I think f:metadata is
> not processed for all requests.
>
> As you want to register this listener to the view root it should be a child
> of f:view (or at least a "top level" tag if you don't use f:view).
>
> regards
> Michael
>
> Am 13.07.2010 14:37, schrieb Marcus Büttner:
>
>  Hi,
>>
>> is there a possiblity to trigger PreRenderView event when I navigate via
>> action to another page?
>>
>> small example:
>> I'm on page1.xhtml an there's a button:
>>
>> <h:commandButton action="page2"/>
>>
>> page2.xhtml includes:
>>
>> <f:metadata>
>>     <f:event type="preRenderView"/>
>> </f:metadata>
>>
>> When I use the button then page2 is shown but the PreRenderView event is
>> not
>> triggerd. The metadata section is only processed in restore view phase. So
>> the event is triggerd with method GET or with POST without switching page.
>> Is it possible to trigger this event when I navigate via action?
>>
>> Thx, regards Marcus
>>
>>

Re: PreRenderView Event with post navigation

Posted by Michael Kurz <mi...@gmx.at>.
Why do you need to put f:event into f:metadata? If you put it outside 
this works like a charm. I didn't look into the details but I think 
f:metadata is not processed for all requests.

As you want to register this listener to the view root it should be a 
child of f:view (or at least a "top level" tag if you don't use f:view).

regards
Michael

Am 13.07.2010 14:37, schrieb Marcus Büttner:
> Hi,
>
> is there a possiblity to trigger PreRenderView event when I navigate via
> action to another page?
>
> small example:
> I'm on page1.xhtml an there's a button:
>
> <h:commandButton action="page2"/>
>
> page2.xhtml includes:
>
> <f:metadata>
>      <f:event type="preRenderView"/>
> </f:metadata>
>
> When I use the button then page2 is shown but the PreRenderView event is not
> triggerd. The metadata section is only processed in restore view phase. So
> the event is triggerd with method GET or with POST without switching page.
> Is it possible to trigger this event when I navigate via action?
>
> Thx, regards Marcus
>