aspose file tools*
The moose likes JSF and the fly likes Where is doGet() in JSF? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Where is doGet() in JSF?" Watch "Where is doGet() in JSF?" New topic
Author

Where is doGet() in JSF?

Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
When I access servlet from a link or browswe address , doGet() is executed.
How to code a doGet() in JSF Bean?
Thanks.


BJ - SCJP and SCWCD
We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design

Crazy Bikes created by m-Power
Rick Beaver
Ranch Hand

Joined: Dec 14, 2004
Posts: 464
Hi

All JSF actions work by Post unfortunately - you will have to use a normal anchor etc to do a get...


ph34r my 133t j4v4 h4><0r1ng sk177z
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
Thanks.
What is "normal anchor"?
Thanks.
Rick Beaver
Ranch Hand

Joined: Dec 14, 2004
Posts: 464
Hi

I mean you will have to use a normal "a" tag or another standard HTML navigation method.

You can reference a get URL as a src within a JSF component - for an image for example.
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
What I meant was that in a servlet doGet() is the entry point where I can retrieve request parameters etc. How to code such a entry point in JSF bean if my JSF is evoked by url instead of POST?
Thanks.
Rick Beaver
Ranch Hand

Joined: Dec 14, 2004
Posts: 464
Ah, I think I see. So you want to set parameters in your bean via a get instead of a post. To be honest I dont think there is an easy way to do this. There may be a way by querying the FacesContext from your bean but your bean would not actually be able to do anything without a method being called on it - which, in JSF, needs to be done by post.

Can you provide the context of the problem and then it may be easier to provide a workable solution for you?
Michael Valentino
Ranch Hand

Joined: Nov 01, 2005
Posts: 96
Been a little while since I used JSF, but I believe you can access the request parameters from the FacesContext (not sure if that's the correct name or not) object. Check the JSF API for the JSF implementation which you're using. This should work regardless of a GET or POST method.


SCJP 1.4, SCWCD J2EE 1.4, SCJD J2SE 1.5, SCBCD J2EE 1.3, SCDJWS (In Progress)
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
This is what I want to do:

I have a JSF that displays monthly orders. I want to put URL links in regular html page so that each link only gives orders in a particular month:

It seems that bean functions can be associated with JSF tags so that when user clicks submit button these function will be executed.
But how to evoke bean functions when JSF is accessed from URL as shown avove?

Thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16055
    
  21



will probably work. I think there's a cleaner way, but I don't recall it. I've learned to avoid using FacesContext where possible, but sometimes it's not possible.


Customer surveys are for companies who didn't pay proper attention to begin with.
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
Thanks Tim;

In which bean function do we use FacesContext to get values in queryString?
In servlet we have doGet() function. What would be the counterpart of doGet() in JSF?

Thanks.
g madhava
Ranch Hand

Joined: Sep 14, 2001
Posts: 85
Based on the code below:


you are going to show to the user the "order.jsp" jsp page.
This JSP page needs to interact with the managed bean.
Let's say you are displaying "order.jsp" as a table below.



Now you have the JSF Managed Bean declared as "jsf_mb_OrderDisplayBean" in the faces-config.xml corresponding to the class,let's say "com.javaranch.OrderDisplayBean"

This class has a method that "getOrders()" that will display the list of orders


In this method, you can use the code supplied by "Tim Holloway" or my code as below. The one given by "Tim" returns String[].



You ** DO NOT ** need to implement either the doGet() method or either the doPost() method.
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
Thanks g for the explaination.
I finally got it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where is doGet() in JSF?