One issue I've had with JSF is the lack of importance of a URL in the browser. It seems that since everything is a post, it's difficult, if not impossible, to create a web app that considers URLs important. A blog would be a good example. Something like "detail.jsf?id=1234" just isn't something handled well by JSF.
Is this something others have struggled with? I'd be curious to hear any suggestions on how to overcome this in JSF.
This post got me. I couldn't believe that it's not possible, and to my horror found out that if it is in fact possible, it most definately not intuitive, or obvious. So I also started searching, and found one of Balus C's topics that seems to cover it. I am still reading through it, but so far, judging by the intro, it seems to have something to do with this. So thought, while I'm going through it, you could too ;-) Here it is
You can put any GET data into a backing bean by setting a managed property on it. For example, with the URL detail.jsf?id=1234 and a backing bean, foo with a property called id:
and now you can access that property like any other. Note, however, that because this is a managed property it can't be accessed until after construction...create a @PostConstruct function if you can.
Hope this helps ~Zack [ July 03, 2008: Message edited by: Zack Marrapese ]
Joined: Sep 29, 2001
Do you know how to invoke the action when setting a managed property? Say I have a hyperlink to a blog entry, like "detail.jsp?id=123". When that link is clicked, there's no default action or anything, so is there a special component I should use to specify the action I want to execute while passing the id as a GET parameter?
Joined: Sep 29, 2001
A quick update. I used h:commandLink to invoke an action once the link is clicked, however, using the navigation rules in the faces-config only forwards the process to another page, it has no effect on the URL displayed in the browser. That makes it impossible for the user to know the actual URL they are on, and makes it so they can't bookmark it for future reference. How can I get around this?
While that element looked promising, it ends up breaking the application I posted above. When you click the link from the index.jsp page, it does in fact forward to the detail.jsp page, but the ID value of the bean is 0 instead of the value set in the link. It works as expected without the element in the faces-config.xml file.
Ayub ali khan
Joined: Oct 20, 2005
I suggest you have a look at Thisdiscussion so as to decide your approach of implementation.