Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GET method in JSF

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
Any way to use get method with JSF apps ?
I don't know what the hell they were thinking, Why they don't support GET method ?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They were thinking "there's a lot of glop that gets passed back and forth on JSF pages and GET has limitations size, so let's use POST".

If what you you really mean is "Why can't I call up JSF pages using Simple URLS?", you have a lot of company, and hopefully, someday someone will come up with a good solution.

It's perfectly permissible to mix ordinary JSPs/servlets and JSF pages in a webapp, however, so you can aways write something that supports GET, even if it's just going to forward to a JSF page.
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John it isn't that bad. You can call a JSF and use GET.



Suppose I want to call a page with eventID=1234 and the jsp file is init.jsp then

domain/init.faces?eventID=1234

Will do the job. Just add the code below the taglib declaration in your JSP.

Now suppose I put a welcome declaration as index.jsp then write this and only this in the index.jsp file



Then you can call

domain/?eventID=1234

And get the same result. For domain I mean the URL with or without 8080 depending on your config.

Now the handy thing about this is that if the eventID isn't set the eventID setter isn't called. So this gets really interesting for initialization purposes. If my faces is called through "GET" with a valid eventID then the eventID setter is called and I can do initialization steps. On all further requests to the faces the GET params are stripped so initialization is automatically skipped.

But yes JSF still gives me the "oh thats they way they wanted this done, hmmm"
 
Daniel De Leon
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An other option is in JSF on the JSP file.
Set the property before these Tags:
<jsp:root ../>
<jsp:directive.page ../>

<jsp:setProperty name="mySessionBeanLoadedFrom_faces-config.xml_file" property="eventID" />

and you Got it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic