File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSF: calling a page without calling a page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSF: calling a page without calling a page" Watch "JSF: calling a page without calling a page" New topic
Author

JSF: calling a page without calling a page

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Ok, I know the subject seems odd. Basically, what I do now with plain jane JSP and Servlets is I will call a servlet which forwards to a view. That way, I never have actualy page.jsp in the URL. I always just have an action like
http://localhost/action/viewform
What I want to know is if there is a way to do this using JSF or if I still will do it like I am now, but the view just happens to be a JSF. I hope this makes sense.
Also, #2 part of this...
I will often use a Servlet to forward to a view simply to populate comboboxes and lists. So with the url above the viewform servlet will just throw some objects[] in the request that I foward on to the page to populate my lists and drop downs.
What is the best method of doing this using JSF?
Thanks.
[ March 05, 2004: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Bill Dudney
Author
Ranch Hand

Joined: Sep 05, 2003
Posts: 234
Hi Greg,
Well on the first point. I'm not sure how that would work with JSF. JSF uses the incoming URL as the 'view id' and that is how it finds the existing view on the server (unless the view was serialized in the page). So if you had a bunch of pages that all when through the viewform servlet then JSF would get lost.
You can configure the FacesServlet one of two ways, /faces/* or *.jsf (or another extension but takes more configuration). either way relies on putting the name of the view into the URL...
For part 2: In stead of having your servlet do the fetching one of the managed beans would do that in the 'getTheList' method and your pulldown would be populated like this


I know this is probably hard to follow without all the code. Keep an eye on my blog. In a week or so I hope to have most of the code up there.


TTFN,<br /> <br />-bd-<br /> <br /><a href="http://www.amazon.com/exec/obidos/ASIN/0471449156/qid=1064343733/sr=2-1/ref=sr_2_1/002-8375300-3666449" target="_blank" rel="nofollow">Jakarta Pitfalls</a> | <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0471146153/qid=1064343733/sr=1-2/ref=sr_1_2/002-8375300-3666449?v=glance&s=books" target="_blank" rel="nofollow">J2EE AntiPatterns</a> | <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0471462071/qid=1064343733/sr=1-3/ref=sr_1_3/002-8375300-3666449?v=glance&s=books" target="_blank" rel="nofollow">Mastering JavaServer Faces</a> | <a href="http://bill.dudney.net/roller/page/bill" target="_blank" rel="nofollow">Blog</a> | <a href="http://www.jroller.com/page/BillDudney" target="_blank" rel="nofollow">Eclipse Blog</a> | <a href="http://www.sourcebeat.com/TitleAction.do?id=2" target="_blank" rel="nofollow">Eclipse 3 Live</a>
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Your example makes perfect sense. I was wondering if I would be able to do it in the bean, but I wasn't sure how to approach it. Now I know.
Thanks for the help.
As far as #1, that kind of sucks. I really prefer not to display my technology that I am using in the URL.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSF: calling a page without calling a page