It's not a secret anymore!*
The moose likes JSF and the fly likes How to get the whole URL like http://localhost:8080/webcontext/page.jsf?event=23&lang=1 in add bar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to get the whole URL like http://localhost:8080/webcontext/page.jsf?event=23&lang=1 in add bar" Watch "How to get the whole URL like http://localhost:8080/webcontext/page.jsf?event=23&lang=1 in add bar" New topic
Author

How to get the whole URL like http://localhost:8080/webcontext/page.jsf?event=23&lang=1 in add bar

Navdeep Singh kanwal
Greenhorn

Joined: Dec 19, 2011
Posts: 9
Hi Friends,
I have been facing a serious problem , Please help me out.
Problem :

Currently we have url somewhat like:
http://localhost:8080/webcontext/page.jsf
it does not change with page change, As we do not have individual page Because we fetch the data from db on clicking of menu and it gets rendered in the page internally.
we want that when user clicks some menu the url changes automaticall according to the required values like we have here below:
http://localhost:8080/webcontext/page.jsf?event=23&lang=1
So that i can let the user to go forward and backward from the browser buttons.

I have solution for this but that does not seem to be satisfied
Solution : i have redirected the page to this customized url on every click, i use to build the url on my own after clicking the menu,

Can i have any better solution Becuase it is creating some performance issues, becuause its redirects property.

Thanks and Regards

Navdeep Singh (Kanwal Ror)
Sofware Developer
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

In JSF, the URL is not so much a page locator as it is a session "handle", which is why it doesn't track directly to views.

Trying to work directly brute-force with URLs in JSF can be a problem, however. Quite aside from the fact that they make even getting the URL difficult (JSF is built on an abstraction and doesn't assume that the app is always based on the web or servlets). JSF makes extensive use of form postbacks, which are HTTP POST-based, so the same logic that got entered originally via an HTTP GET may spend most of its life dealing with POST.

All is not lost, however. JSF2 added better support for "bookmarkable" JSF URLs. Also, you can install and use the PrettyFaces add-on from OCPsoft (ocpsoft.com), which I think is a subsidiary of Red Hat JBoss these days. At least Lincoln Baxter, who created PrettyFaces (and occasionally visits here) works for JBoss these days.

PrettyFaces makes bookmarkable URLs trivial. You basically add a small jar to WEB-INF/lib, put in a minor addition to web.xml, and add annotations to the backing beans that you want to have bookmarkable URLs. Or, if you prefer, use the legacy pretty-config.xml file.

PrettyFaces works on the idea that you provide a URL template that allows you to define a simple bookmarkable URL in the format you want, plus optional URL parameters which are mapped to backing bean properties. Once you do that, the actual Java code becomes POJO: the URL fires an action method, and when the action is invoked, the URL parameters have been pre-injected into their corresponding bean properties automatically.

However, I don't think that a bookmarkable URL alone is going to resolve issues with the forward and back browser buttons. That's a whole different can of worms.


Customer surveys are for companies who didn't pay proper attention to begin with.
Navdeep Singh kanwal
Greenhorn

Joined: Dec 19, 2011
Posts: 9

So you mean we do not have any solution in JSF1.2.
I have one more question:
Can i Use PrettyFaces As i am using RichFaces Already in my project??
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

I can, I have, and it was using JSF1.2.
 
jQuery in Action, 2nd edition
 
subject: How to get the whole URL like http://localhost:8080/webcontext/page.jsf?event=23&lang=1 in add bar
 
Similar Threads
How to change to secure ?
How to hide the parameters in the URL??
In struts , Hyperlink not woking well
Tomcat web app configuration error
sslext with tiles. URL shows .jsp instead of .do