Package arez.dom
Class BrowserLocation
java.lang.Object
arez.dom.BrowserLocation
This is a simple abstraction over browser location as a hash.
The model exposes the observable values for the location as the application sees it via
getLocation()
, the way the browser sees it via getBrowserLocation()
.
The application code should define an observer that monitors the location as the browser
sees it and update the location as the application sees it via changeLocation(String)
if the browser location is valid. Otherwise the browser location should be reset to the application
location.
It should be noted that this class is not a router but a primitive that can be used to implement a router. Observing the application location will allow the application to update the view. Observing the browser location will allow the application to decide whether the route should be updated.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
changeLocation
(String targetLocation) Change the target location to the specified parameter.static BrowserLocation
create()
Create the model object.Return the location as the application sees it.void
Revert the browsers location to the application location.void
setPreventDefault
(boolean preventDefault) Set a flag to determine whether events default action will be prevented.boolean
Return true if component will prevent default actions when hash.
-
Method Details
-
create
Create the model object.- Returns:
- the BrowserLocation instance.
-
shouldPreventDefault
Return true if component will prevent default actions when hash.- Returns:
- true if component will prevent default actions when hash.
-
setPreventDefault
Set a flag to determine whether events default action will be prevented.- Parameters:
preventDefault
- true to prevent default action.
-
changeLocation
Change the target location to the specified parameter. This will ultimately result in a side-effect that updates the browsers location. This location parameter should not include "#" as the first character.- Parameters:
targetLocation
- the location to change to.
-
resetBrowserLocation
Revert the browsers location to the application location. -
getLocation
Return the location as the application sees it. This return value does not include a "#" as the first character.- Returns:
- the location.
-
getBrowserLocation
-