voyent
How can I get the mobi:geolocation before firing an event on the page?  XML
Forum Index -> ICEmobile General
Author Message
bcantu

Joined: 02/Nov/2009 00:00:00
Messages: 45
Offline


At the moment the user has to first press a search button that will pass the longitude and latitude values from the mobi:geolocation component to the bean and search the database.

I would like to search the database for a given location before loading the page and having the user press the search button. Is this possible?
philip.breau


Joined: 08/May/2006 00:00:00
Messages: 2989
Offline


The geolocation coordinates are automatically retrieved from the browser when the page loads, so you have to load the page first before you have them. Once they're loaded in the browser, you can make an ajax call back to server. Currently you'll have to do this yourself, but I think adding a new feature to the mobi:geolocation tag to automatically update the server on when the coordinates are updated would be good.

http://jira.icesoft.org/browse/MOBI-1085

For now just try something like this:
Code:
 <h:form id="geoForm">
    <mobi:geolocation id="geo"
              latitude="#{bean.latitude}"
              longitude="#{bean.longitude}" />
    <mobi:commandButton id="btn" style="display:none"/>
    <h:outputScript>
         document.querySelector("#geoForm:geo_locHidden").addEventListener("change", function(){
                 document.querySelector("#geoForm:btn").click();
         }, false);
    </h:outputScript>
 </h:form>
 


Thanks,
Philip

.
 
Forum Index -> ICEmobile General
Go to:   
Powered by JForum 2.1.7ice © JForum Team