Naresh Bhatia wrote:
Hi Simon,

Thanks for a quick response.

When I said "navigates through a link", I had first tried h:commandLink.
However, as you mention below, it was posting back to page A and causing
an unnecessary database read (I was doing lazy loading in my bean and
since this was a brand new bean, it was hitting the DB for no good
reason).

I think you'll find that if you mark your h:commandLink as immediate="true" then the getters that are triggering the database read will not occur. That's what the immediate flag is for - navigation links that are meant to NOT push data into the backing model. You can then use normal JSF navigation rather than working around it.

http://wiki.apache.org/myfaces/How_The_Immediate_Attribute_Works

 Therefore, I switched to a raw <a> tag. Surprisingly enough, I
was able to make it work painlessly. Here's my code:

<a
href="#{ctx}/pages/ShowForum.jsf?forumId=#{forum.id}">#{forum.title}</a>

Hmm..you've got the JSF client id "forumId" hard-wired there, ie this code is assuming that the component it wants to pass the data to has precisely this id, and is not nested within any naming container. It will work fine for most uses, but isn't perhaps in the full spirit of JSF.



Note that I am using Facelets as my view handler. Of course, I don't
like this approach too much, because now my navigaion code is sitting in
the page instead of faces.config. These are some of the reasons why
asked my original question about the best ways to save state.



Regards,

Simon

Reply via email to