Class BasePage

All Implemented Interfaces:
Animatable<Container>, CanDrop<Container>, Clickable<Container>, Draggable<Container>, HandleMouseEvents<Container>, Scrollable<Container>, Touchable<Container>
Direct Known Subclasses:
BaseLoginPage

public class BasePage extends Container

The base page class

Every page in the application must extend this class. This class is responsible for ensuring that the basic functions of the page(s) are working, and supplies the basic, mandatory methods.

Since:
4.0
Author:
JBStrap
  • Field Details

    • params

      protected Parameters params
      The parameters that are assigned to the page
  • Constructor Details

    • BasePage

      public BasePage(UI ui, Parameters params)
      Creates a page. The constructor must be called upon instantiating a page.
      Parameters:
      ui - The UI object instance, where the page will appear.
      params - The Parameters class, containing the parameters assigned to the page.
      Throws:
      IllegalStateException - If the page is set to be both Private and Public.
      See Also:
  • Method Details

    • writeHTML

      public boolean writeHTML(StringWriter writer)
      Description copied from class: Component
      Creates the component's HTML equivalent

      This method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (StringWriter class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return with false. Otherwise, it must return with true.

      Overrides:
      writeHTML in class Container
      Returns:
      If the componentwas drawn, true, otherwise false
    • addResizeHandler

      public void addResizeHandler(PageResizeEventHandler handler)
      Adds the specified resize handler to the page. This handler will run when the user resizes the page.
      Parameters:
      handler - The PageResizeEventHandler implementation
      See Also:
    • getPageId

      public final String getPageId()
      Gets the page ID
      Returns:
      The page ID
    • getTitle

      public final String getTitle()
      Gets the page title. If there is a parameter that is named "title", the method will return its value. If not found, returns with null
      Returns:
      The page title or null, if no title was specified
      See Also:
    • setTitle

      public final BasePage setTitle(String pageTitle)
      Set the page title
      Parameters:
      pageTitle - The page title. If set null or empty string, page title is not used
    • getParameters

      public Parameters getParameters()
      Gets every parameter that is assigned to the page.
      Returns:
      The Parameters object containing every parameter assigned to the page
      See Also:
    • equals

      public boolean equals(Object obj)
      Determines if the specified object equals the page. The specified object is considered equal if the following are true:
      • The name of the specified object is null
      • The specified object is a BasePage, or extends from it
      • The name of the specified object has the same page ID as the page.
      • The parameters of the specified object is equal to the parameters of the page. (Parameters.equals())
      Overrides:
      equals in class Object
      Returns:
      true, if the specified object is equal, otherwise false
    • addUrlParameter

      public final BasePage addUrlParameter(String name, String value)
      Adds a URL parameter to the page. If a URL parameter is added to the page, it will be in the URL that appears in the browser. If a user saves the URL to their bookmarks, or sends it in an e-mail, the parameter will be saved/sent as well. If the user uses the URL to open the page, the parameter in the URL will also be placed among the page parameters.
      Parameters:
      name - The name of the parameter
      value - The value of the parameter. The parameter can only contain a value that can be placed in the URL (text, number, etc.).
      Returns:
      The page
      Throws:
      NullPointerException - If the specified parameter name or value is null
    • removeUrlParameter

      public final BasePage removeUrlParameter(String name)
      Removes the specified parameter from the page URL
      Parameters:
      name - The name of the parameter that will be removed
      Returns:
      The page
      Throws:
      NullPointerException - If the specified parameter name is null
    • getUrlParameter

      public String getUrlParameter(String name)
      Gets the parameter value of a URL Parameter
      Parameters:
      name - The name of the parameter
      Returns:
      The parameter value or null, if the specified parameter was not found in the page url parameters