aspose file tools*
The moose likes JSF and the fly likes JSF post form data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF post form data" Watch "JSF post form data" New topic
Author

JSF post form data

Kevin Gutch
Greenhorn

Joined: May 17, 2001
Posts: 6
Hi,

This is probably a very basic problem but I am not sure how to solve it.
I would like to use a commandLink actionListener to post some data to a specific URL as such http://api.mypage?data1=.

However, I do not want to go to the page (which is what happens if I post the form from a commandLink).

Can anyone suggest a method for doing this?

Thanks

Kevin
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

HTTP is a request/response protocol. Regardless of whether you're programming in JSF, Struts, raw JSP, servlets, or even Perl or Python, assembly Lnaguage, C or FORTRAN, the #1 rule is this:

For every request there must be a response.

It's why no HTTP service can ever do do true MVC - an HTTP server cannot send out an unsolicited response, and it's why you can't have what you want; every request must be followed by a response. Even AJAX isn't immune to that most fundamental of strictures.

On the other hand, in JSF, the default response is to redisplay the requesting JSF page, so visually it makes no difference other than a delay and maybe a screen flicker.

If, however, you want your page to post data to some other location and remain on the current page, what you can do is have the JSF action method do an HttpURLConnection request from the JSF server to the other location. Which can be on the same server or any other server in the world, as long as the JSF server can access it. The Secondary server must response with something, since it's subject to the First Law of HTTP, although a simple empty "200 OK" status is good enough. Once your JSF backing bean's action method sees that response, it can then complete its action - or, if something went wrong, it can throw an exception or something.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF post form data
 
Similar Threads
How to read XML data
string getting converted to ASCII
Testing
passing hidden field value to backing bean
Pattern & Matcher - how to get any combination?