Package arez.dom

Class BrowserLocation

java.lang.Object
arez.dom.BrowserLocation

@ArezComponent(requireId=DISABLE) public abstract class BrowserLocation extends Object
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 Details

    • create

      @Nonnull public static BrowserLocation create()
      Create the model object.
      Returns:
      the BrowserLocation instance.
    • shouldPreventDefault

      public boolean shouldPreventDefault()
      Return true if component will prevent default actions when hash.
      Returns:
      true if component will prevent default actions when hash.
    • setPreventDefault

      public void setPreventDefault(boolean preventDefault)
      Set a flag to determine whether events default action will be prevented.
      Parameters:
      preventDefault - true to prevent default action.
    • changeLocation

      @Action(verifyRequired=false) public void changeLocation(@Nonnull String targetLocation)
      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

      @Observable @Nonnull public String getLocation()
      Return the location as the application sees it. This return value does not include a "#" as the first character.
      Returns:
      the location.
    • getBrowserLocation