public abstract class AjaxGeolocationBehavior
extends org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
Constructor and Description |
---|
AjaxGeolocationBehavior() |
Modifier and Type | Method and Description |
---|---|
int |
getTimeout()
Returns the current timeout in milliseconds.
|
protected void |
onBind() |
protected abstract void |
onGeoAvailable(org.apache.wicket.ajax.AjaxRequestTarget target,
String latitude,
String longitude) |
protected void |
onNotAvailable(org.apache.wicket.ajax.AjaxRequestTarget target,
String errorCode,
String errorMessage)
Override this method if you want to react on the event that
no geolocation could be determined.
|
void |
renderHead(org.apache.wicket.Component c,
org.apache.wicket.markup.head.IHeaderResponse response) |
protected void |
respond(org.apache.wicket.ajax.AjaxRequestTarget target) |
void |
setTimeout(int timeout)
Sets the timeout in milliseconds.
|
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, onRequest, postprocessConfiguration, renderAjaxAttributes, renderAjaxAttributes, updateAjaxAttributes
afterRender, bind, getCallbackUrl, getComponent, onComponentRendered, onComponentTag, onComponentTag, onUnbind, unbind
protected void respond(org.apache.wicket.ajax.AjaxRequestTarget target)
respond
in class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
protected abstract void onGeoAvailable(org.apache.wicket.ajax.AjaxRequestTarget target, String latitude, String longitude)
protected void onNotAvailable(org.apache.wicket.ajax.AjaxRequestTarget target, String errorCode, String errorMessage)
target
- the AjaxRequestTargeterrorCode
- the numeric code for the reason no geolocation could
be determined as specified by the W3C
(@see http://dev.w3.org/geo/api/spec-source.html#position_error_interface).errorMessage
- describes the details. Primarily for debugging purposesprotected void onBind()
onBind
in class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
public void renderHead(org.apache.wicket.Component c, org.apache.wicket.markup.head.IHeaderResponse response)
renderHead
in interface org.apache.wicket.markup.html.IComponentAwareHeaderContributor
renderHead
in class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
public int getTimeout()
setTimeout(int)
public void setTimeout(int timeout)
onNotAvailable
method is called, passing a "3" as
an error code.
The specification (http://dev.w3.org/geo/api/spec-source.html#position_error_interface)
defines also a timeout attribute:
"The length of time specified by the timeout property has elapsed
before the implementation could successfully acquire a new Position
object."
So it applies only for the case the user grants permission to share
his location and is NOT the timeout which is set in this method!
It MIGHT happen that the determination of the location takes a bit
longer, even though the user granted permission to share his location.
In this case first onNotAvailable(org.apache.wicket.ajax.AjaxRequestTarget, java.lang.String, java.lang.String)
will be called and as soon as the location could be obtained
onGeoAvailable(org.apache.wicket.ajax.AjaxRequestTarget, java.lang.String, java.lang.String)
will be called. So don't set the timeout too low.
The default timeout is set to 10 seconds.Copyright © 2015. All rights reserved.