File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript call bean setter

 
victor bernado
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to develop a mobile application with JSF2 and PrimeFaces.
At home page I have a GoogleMap and a JavaScript that find the current location and locate it at the map:

I have a GeoLocationBean that hold latitude and longitude, and I want that when findMe() has been executed call the geolocationBean.setLatitude( long ) and geolocationBean.setLongitude( long ) method.
There are any way to do it throw javascript?

A solution that I found (but it doesn't work) is:
- javascript update a hide element that hold latitude
- the hide element has an f:ajax that when valuechanged occurs, call setLatitude.
but valuechanged occurs only if user type in the inputtext

the complet index.xhtml file is:


Thanks
VĂ­ctor
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17625
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way to get javascript to read or write to a server-side object (JSF backing bean) is to use AJAX. JavaScript runs only on the client, so the backing bean and the script reside on separate computers.
An "onclick" handler should end with a "return true" or "return false" in order to tell the control whether it should submit the form after it has run the findMe() js function.

You should be able to retrieve the form's current latitude value by locating the DOM object whose ID is "latitude". Normally it would be "formid:latitude", but you switched off the form's prependid attribute. Longitude, of course, follows the same strategy.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic