Renderer difference
Hi
I have spent a couple of hours to make a result pagination in jsf.
<h:commandLink actionListener="#{goodbyeBean.prev}" >
<h:outputText value="prev" rendered="#{goodbyeBean.pageNo > -3}"/>
<f:param value="#{goodbyeBean.pageNo - 1}" name="pageNo"/>
</h:commandLink>
<h:commandLink actionListener="#{goodbyeBean.next}">
<h:outputText value="next" rendered="#{goodbyeBean.pageNo < 0}"/>
<f:param value="#{goodbyeBean.pageNo + 1}" name="pageNo"/>
</h:commandLink>
goodbyeBean is a request bean. On the first page i hide next link and then when pageNo = -3 i hide prev link.
I have spent so much time and finally found solution for hiding links- which i present above. In a first turn, i had render attribute set to commandLink tag, i.e.
<h:commandLink actionListener="#{goodbyeBean.next}" rendered="#{goodbyeBean.pageNo < 0}">
<h:outputText value="next"/>
And i had a real problems with next link. On the first page i had a chance to click on prev - which is ok. When the page was redispalyed next link appeared, but if i clicked it , goodbyeBean.next function wasn't fired.
Update Model phase was reached cause i saw a new value in pageNo http request parameter but that's all.
If i clicked prev link twice and then click next everything seems to be ok and goodbyeBean.next is fired. But this time i should also be able to click on next again (i had clicked prev twice before) but goodbyeBean.next isn't fired again after the second next click.
I found solution in one of the example but can anyone explain me this weird behaviour ?
[1712 byte] By [
milucha] at [2007-10-2 4:31:09]

Here's some info from the book core JavaServer Faces.
Action events are fire by command components when the component is activated. They are fired during the Invoke Application phase, near the end of the lifecycle.
It's important to distinguish between action listeners and actions. In a nutshell, actions are designed for business logic and participate in navigation handling, whereas action listeners typically perform user interface logic and do not participant in navigation handling.
It is possible in your case that it's not working sometimes because the Invoke Application phase is being skipped. That makes sense because on page load the phases encountered are Restore View and then it jumps to Render Response.
Looma at 2007-7-16 0:01:03 >

Hi
Switching to action doesn't change anything. No changes.
As i wrote before i have a solution to my problema but i would like to know what it means to add renderer attribute to h:commandLink.
And what happens if this link finally appears.
> That makes sense because on page load
> the phases encountered are Restore View and then it
> jumps to Render Response.
I do not get it. If i click on prev link i have my action fired. The result of this action is redisplayed page but this time i show next button. If i click on next ,lifecycle of JSF should start again. And if i bind link or button to some bean's method this method should be fired.
So i do not get that on page load the phases encountered are Restore View and then it jumps to Render Response. I think this scenario happens if i i type URL to browsers address bar. But in my situation the page was redispalyed because i clicked command link (what is equals to clicking on submitt button).
> I've tried your code and found that it works with no
> problem even if
> the scope is request.
> So, your problem may exist in some code you haven't
> shown yet.
> Firstly, put <h:messages/> into your JSP and see
> whether there is any error.
It is great that you spent your time to test my code. I have <h:messages/>
set in my JSP and i do not have any errors or other problems.
Anyway can you explain me the difference between having renderer attribute set to <h:commandLink> and having it set to <h:output> nested in <h:commandLink>.
When I moved the rendered attribute to the surrounding commandLink,
I found the same problem as yours; the next actionListner never invoked.
This is the situation firstly I guessed.
After clicking the button, JSF traverses the component tree to decide to activate
events. Because the bean is initialized at that time, the value binding expression
for the rendered attibute is evaluated as false and the commandLink component
is skipped; so the event is not activated.
When the rendered attribute is put into the outputText, the traverse reaches the
commandLink and the event is activated.
In another situation, if the bean's scope is session, the rendered attribute holds
to be true and the traverse reaches the commandLink.