• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF URL with parameter

 
nikos karanikos
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am goind to the page faces/excursion1.xhtml?id=2 where i have a form but when the user complete the form but something is not valid instead of going to the page faces/excursion1.xhtml?id=2 it goes to the faces/excursion1.xhtml is there a way to fix this?
Thank you
 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The page "abc.jsf" and the page "abc.jsf?arg1=1" are the same page.

The URL is comprised of several discrete parts:

1. The protocol ID (more precisely the "URI Scheme"). For example, "http"

2. The server credentials (usually omitted). For example, "archimedes:password"

3. The server IP address or domain name. For example, "www.coderanch.com"

4. The Application context path. For example "webapp1"

5. The Application resource Identifier. For example, "admin/editUser.jsf"

4. The query string. For example, "user=tomsmith&set=inactive". Not all URLs support one. For example, HTTP POST URLs should not have a query string, since the posted data contains the query data, not the URL.

5. The anchor reference, which is usually exclusive with a query string. For example, "#paragraph1". This instructs the browser to shift part of the returned HTML so that the part of the page that contains anchor element "paragraph1" is in the displayed window (scrolling the page, if needed).

So, putting items 1-4 together:

http://archimedes:password@www.coderanch.com/webapp1/admin/editUser.jsf?user=tomsmith&set=inactive

The query string, as mentioned, does not reference a page, it's parameter data that's passed along to the page processor. The URL parser breaks it down into name/value pairs and attaches these pairs to the HttpURLRequest object.

In JSF, of course, an application resource identifier doesn't literally access an WAR resource. It's used as data by the FacesServlet and Facelets processors, which decompose it and use it to build the WAR resource path that's used as the primary View template. Which is how "/admin/editUser.jsf" causes the template at "/admin/editUser.xhtml" to be employed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!