You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Stefan Kohler <st...@peekus.com> on 2009/11/23 17:47:29 UTC

t:panelNavigation rerendering source page

Hi there!

Maybe some can explain this to me - it might be a general JSF
misunderstanding I am having.

I'm using t:panelNavigation + t:commandNavigation to have a 'navigation'
on every jsf page. When pressing one of the t:commandNavigation items it
causes a reload of the current page I am on before executing the action
specified.

The behaviour I would expect would not be a request to the current page I
am on but to the new page w/o rendering the old one. My problem is that
the request to the old page causes a query to the database causing
performance problems - as it is loading not needed data! I read through
the documentation and couldn't find any possible solution (checked the
lifecycle in particular:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSFIntro10.html).

I think the problem is that the t:commandNavigation needs to be nested in
a form that is submitted by clicking on one of the items. Does this cause
the whole page to be rerendered? Am I getting anything wrong here? Maybe
someone can give me some hints where to look or what might be wrong.

Thank you!

- Stefan

Re: t:panelNavigation rerendering source page

Posted by Stefan Kohler <st...@peekus.com>.
> Stefan Kohler pisze:
>> Maybe some can explain this to me - it might be a general JSF
>> misunderstanding I am having.
>
> Could be the latter.
>

I thought so, too! Thanks for the reply! This problem kept me thinking
about the same things you mentioned, do I really need a Faces Reqeust or
should I do a Non-Faces Request instead. Also, I kept reading the docs and
thought - OK, the panelNavigation is in a form, by clicking a link I
submit this form, but only this form - right? Some further debug should
that the 'old' page was accessed again in the APPLY-REQUEST-VALUES phase,
which had me thinking it is being submitted as a form - but I didn't have
a form-Tag around the content of the page.

Basically that's what I did to get rid of the problem, I added a form-Tag
to surround the content of the page and after that it wasn't submitted /
accessed / processed when clicking one of the links in the navigation.

Does this sound like a reasonable solution? It works for me now, but could
an extra (not needed) form have some other impacts? I don't think it does,
but maybe someone has experienced the opposite?

> The whole idea of JSF is that you build a tree of components and they
> handle things like navigation, actions etc. That's much different from
> what action oriented frameworks do, and has some unexpected implications.
>
> Pressing the commandNavigation must be processed by the
> commandNavigation component itself, not some other entity. And the only
> way of reaching your commandNavigation is for JSF to rebuild the whole
> component tree (actions taken may depend on state of some other
> controls). This is exactly why your original page gets reloaded. Actions
> and things like navigation, I believe, are processed in one of the last
> phases (Invoke Application), just before rendering the page, but after
> building the component tree.
>
> If you don't need all the above, you shouldn't be using
> commandNavigation, an ordinary link would do. If you still want to use
> it, try immediate='true'. This should cause your action to be processed
> during 'apply request values' phase. Depending on how your backing beans
> work, this could solve your problem.
>

I tried immediate='true', too, but that didn't help in my case!

> Hope this helps,
> Filip Dreger
>

In fact your explenations did help me understand JSF a little better,
thank you very much!



Re: t:panelNavigation rerendering source page

Posted by Filip Dreger <fi...@fiok.pl>.
Stefan Kohler pisze:
> Maybe some can explain this to me - it might be a general JSF
> misunderstanding I am having.

Could be the latter.

The whole idea of JSF is that you build a tree of components and they 
handle things like navigation, actions etc. That's much different from 
what action oriented frameworks do, and has some unexpected implications.

Pressing the commandNavigation must be processed by the 
commandNavigation component itself, not some other entity. And the only 
way of reaching your commandNavigation is for JSF to rebuild the whole 
component tree (actions taken may depend on state of some other 
controls). This is exactly why your original page gets reloaded. Actions 
and things like navigation, I believe, are processed in one of the last 
phases (Invoke Application), just before rendering the page, but after 
building the component tree.

If you don't need all the above, you shouldn't be using 
commandNavigation, an ordinary link would do. If you still want to use 
it, try immediate='true'. This should cause your action to be processed 
during 'apply request values' phase. Depending on how your backing beans 
work, this could solve your problem.

Hope this helps,
Filip Dreger