This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsf post to a page

 
subu ananthram
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I would like to post to a form given an URL how do I do this in jsf What we actually want to do is post from smart phones to an URL
and get back a response from it...
i.e http://www.myform.com is some kinda servlet and I post to this
 
subu ananthram
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi
I am really banging my head over this we are developing an application using JSF and I would like to be able to POST to a specific url and on POST I want to invoke a action method
How do I do that in JSF i.e no command button or command link we just want to do http://blablabla.com/app/handle.iface and post to that url somehow and then trigger an action
I could normally do http://blablabla.com/app?action=doStuff and it would trigger doStuff method how do I do it using a url in jsf
Cheers
Priya
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18094
48
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
subu ananthram wrote:

I could normally do http://blablabla.com/app?action=doStuff and it would trigger doStuff method


No you wouldn't. That behavior is something that a special Struts action processor does, and in fact, I stopped using Struts before it even became available. I think it came in with Struts 1.2. One reason I don't do Struts anymore was because of awkward constructs like that.

JSF is based on presenting a View with a Form in it and posting back the Form data, repeating until the action process indicated that a different View was needed. Handling raw GET/POST requests isn't what JSF is all about. However, you can mix servlets, raw JSPs and even Struts actions with JSF if you need to, and they would process POST requests in the normal way.

There are also 2 alternatives within JSF. One is to get the HttpRequest object from the internal JSF context and extract the data by brute force. I don't really recommend this, as it detracts from the portability and testability of the JSF backing beans. Another is to use the PrettyFaces add-on for JSF, but I think that that only works on GET requests.
 
Srini Mutpur
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

We can work out this using some alternative approach.

Create invisible h:commandButton inside the same form and click it using javascript on hyperlink click event.

<h:commandButton id="VButton" action="#{managedBean.myAction}" style="display:none;"/>



function submitAction(){
document.getElementById('VButton').click();
}

Hope it may solve your problem.

Srini
 
subu ananthram
Ranch Hand
Posts: 102
posted 6 years ago
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems wrong that I need to use hidden buttons to trigger actions on a form what if I needed to write a REST based webservice ?
I will try your option Thanks for your time
Cheers
Priya
 
Srini Mutpur
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The other option would be make an ajax call onclick on hyperlik and get the response and process it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic