• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsf post to a page

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The other option would be make an ajax call onclick on hyperlik and get the response and process it.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic