Class AjaxGeolocationBehavior
java.lang.Object
org.apache.wicket.behavior.Behavior
org.apache.wicket.behavior.AbstractAjaxBehavior
org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
org.wicketstuff.html5.geolocation.AjaxGeolocationBehavior
- All Implemented Interfaces:
Serializable,IComponentAwareEventSink,IRequestListener,IComponentAwareHeaderContributor,IClusterable
- See Also:
-
Field Summary
Fields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
INDICATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the current timeout in milliseconds.protected voidonBind()protected abstract voidonGeoAvailable(AjaxRequestTarget target, String latitude, String longitude) protected voidonNotAvailable(AjaxRequestTarget target, String errorCode, String errorMessage) Override this method if you want to react on the event that no geolocation could be determined.voidrenderHead(Component c, IHeaderResponse response) protected voidrespond(AjaxRequestTarget target) voidsetTimeout(int timeout) Sets the timeout in milliseconds.Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, onMethodMismatch, onRequest, postprocessConfiguration, renderAjaxAttributes, renderAjaxAttributes, updateAjaxAttributesMethods inherited from class org.apache.wicket.behavior.AbstractAjaxBehavior
afterRender, bind, getCallbackUrl, getComponent, onComponentRendered, onComponentTag, onComponentTag, onUnbind, unbindMethods inherited from class org.apache.wicket.behavior.Behavior
beforeRender, canCallListener, detach, getStatelessHint, isEnabled, isTemporary, onAttribute, onConfigure, onEvent, onException, onRemove, onTagMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.wicket.IRequestListener
rendersPage
-
Constructor Details
-
AjaxGeolocationBehavior
public AjaxGeolocationBehavior()
-
-
Method Details
-
respond
- Specified by:
respondin classAbstractDefaultAjaxBehavior
-
onGeoAvailable
-
onNotAvailable
Override this method if you want to react on the event that no geolocation could be determined.- Parameters:
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).
"1" indicates a "permission denied"
"2" indicates that the position could not be determined
"3" indicates a timeouterrorMessage- describes the details. Primarily for debugging purposes
-
onBind
protected void onBind()- Overrides:
onBindin classAbstractDefaultAjaxBehavior
-
renderHead
- Specified by:
renderHeadin interfaceIComponentAwareHeaderContributor- Overrides:
renderHeadin classAbstractDefaultAjaxBehavior
-
getTimeout
public int getTimeout()Returns the current timeout in milliseconds.- See Also:
-
setTimeout
public void setTimeout(int timeout) Sets the timeout in milliseconds. If the user is ignoring the request for sharing his location or postpones his decision (in Firefox the "Not now" option) no callback method is called. This is intended by design (see https://bugzilla.mozilla.org/show_bug.cgi?id=650247 ). For those cases we can set a timeout. After the specified amount of time theonNotAvailable(org.apache.wicket.ajax.AjaxRequestTarget,java.lang.String,java.lang.String)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 firstonNotAvailable(org.apache.wicket.ajax.AjaxRequestTarget, java.lang.String, java.lang.String)will be called and as soon as the location could be obtainedonGeoAvailable(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.
-