Friday 15 January 2010

java ee - how to Hide JSF URL after the application name? -


I have a JSF application and I want to hide the URL and when I switched between pages only the name of the application in the URL Want to keep / P>

The URL that I have:

  & gt; Http: // localhost: 8080 / planningdrevelopweb / face / admin / admin-head.exmhtml & gt; Http: // localhost: 8080 / planningdrap web / face / quasson / home. XHTML   

And it always wants that:

  & gt; Http: // localhost: 8080 / PlanificationDrapageWeb /   

How do I get this result?

As Mavarosi said that you can use the prefix to rewrite your URL . Their documents are very useful and very clear. Here are the steps to follow (without the Maven dependency approach): 1) Download the latest jar based on your JSF version and place it in your project classpath.
2) web.xml & lt; Filter & gt; & Lt; Filter-name & gt; Beautiful filter & lt; / Filter-name & gt; & Lt; Filter range & gt; Com.ocpsoft.pretty.PrettyFilter & lt; / Filter range & gt; & Lt; / Filter & gt; & Lt; Filter-mapping & gt; & Lt; Filter-name & gt; Beautiful filter & lt; / Filter-name & gt; & Lt; URL pattern & gt; / * & Lt; / URL pattern & gt; & Lt; Dispatcher & gt; Next & lt; / Dispatcher & gt; & Lt; Dispatcher & gt; Request & lt; / Dispatcher & gt; & Lt; Dispatcher & gt; Error & lt; / Dispatcher & gt; & Lt; / Filter-mapping & gt;

3) Create web-INF under a file: pretty-config.xml which will define your beautifulfus mapping, like This one:

  & lt; Pretty-config xmlns = "http://ocpsoft.com/prettyfaces/3.3.0" xmlns: xsi = "http://www.w3.org/2001/ XMLSchema-Example" xsi: schema location = "http: / /ocpsoft.com/prettyfaces/3.3.0 http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.0.xsd"> & Lt; Url-mapping id = "accueil" & gt; & Lt; Pattern value = "/" /> & Lt; View-ID value = "/ path-to-yourpage.xhtml" /> & Lt; / URL-Mapping & gt; & Lt; Url-mapping id = "error" & gt; & Lt; Pattern value = "/" /> & Lt; View-ID value = "/ tpath-to-yourpage2.xhtml" /> & Lt; / URL-Mapping & gt; & Lt; / Lot-config & gt;   

4) Now when defining results in your managed beans, you should return the beautiful: idOfURLMapping . For example: pretty: accueil gets redirected to the defined page above and usually it appears as the http: // localhost: 8080 / PlanificationDrapageWeb / url Will do
, note that you should only use it when it is a functional requirement. Otherwise, I would use the URL without the extension like Balo has mentioned (his method or if you want advanced attributes functionality).
Edit
Looks like the prefix does not work for this situation. Sorry for the waste of your time.
Now I will suggest another possible solution, because the answer of the ball was removed.
1) You create a new managed bean of the session, call it: PageManagedBean :

  Public category page managed {Private string included Page = "/pages/accueil.xhtml"; // Setters and Gates}   

2) Create a master layout page (Facet templateing):

   & Lt ;! - content - & gt; & Lt; Div class = "page_content" & gt; & Lt; Div class = "page_content_inner" & gt; & Lt; Div class = "container" & gt; & Lt; Ui: Include id = "pageLivre" src = "# {pageManagedBean.includedPage}" /> & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "page_content_footer" /> & Lt; Ui: Include src = "shared / footer.xhtml" /> & Lt; / Div & gt; & Lt; / H: Body & gt;   

Now that you want to change the page, you can only change the page managersbad.Included page values.

No comments:

Post a Comment