• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Making URLs relevant with JSF

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howzit Chris,

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
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

index.jsp


detail.jsp


LoginBean.java


faces-config.xml
 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone?
 
Ranch Hand
Posts: 399
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chris,

I think <redirect/> should be useful for your requirement.

Check Navigation

--Ayub
 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 399
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suggest you have a look at Thisdiscussion so as to decide your approach of implementation.
 
reply
    Bookmark Topic Watch Topic
  • New Topic