• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF Project: How to submit data to and process with Faces Servlet without form?

 
J. Frederik
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a CommandButton that executes "onclick" some javascript that does a client side Google Maps request.
Now I want the Callback function to forward the response to my server via an AJAX request.

I know how I can submit a form via Javascript


But how can I do it without a form?

And how can I make the Faces Servlet process this request (in Java) in a certain way?
 
Tim Holloway
Saloon Keeper
Posts: 18300
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're over-concerned about the FacesServlet.

JSF is not a jealous platform. If you have something that needs doing that doesn't benefit from JSF, don't ram it through JSF. A classic example of that is when people want to produce PDF or spreadsheet documents. I'm constantly cautioning people that a plain old servlet is better for that part of the webapp than hijacking the internals of JSF. Sometimes they even listen to me. :cool:
 
J. Frederik
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your answer.
Of course this is still connected to JSF. But using an extra servlet I do not see the possibility to create validation messages for example as the FacesContext is missing.
 
Tim Holloway
Saloon Keeper
Posts: 18300
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If what you are looking to do is embed a Google Map in a JSF page and make it so that acting on the map (via JavaScript) initiates actions on the server via JSF, that's OK. I actually have such an app, in fact. You click on points on the map and the location gets posted to a database via JSF.

However, the primary architectural constraint is that not only JSF, but HTTP itself requires a form. While you could issue a straight HTTP GET request via AJAX without a form, that doesn't give the benefits that a full JSF form postback would.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic