Class WApplication

    • Constructor Detail

      • WApplication

        public WApplication()
    • Method Detail

      • hasUnsavedChanges

        public boolean hasUnsavedChanges()
        Indicates whether the application has unsaved changes.
        Returns:
        true if there are unsaved changes, otherwise false
      • setUnsavedChanges

        public void setUnsavedChanges​(boolean unsavedChanges)

        Sets the unsavedChanges flag. The unsavedChanges flag is used by the Themes to display a warning message if the user invokes a cancel button and the flag is set to true.

        Parameters:
        unsavedChanges - true if there are unsavedChanges
      • getTitle

        public String getTitle()
        Returns the application's title.
        Returns:
        the applications's title
      • setTitle

        public void setTitle​(String title)
        Sets the application title. The title of the first application in a view is used as the content of the page's TITLE element
        Parameters:
        title - The title to set.
      • isAppendID

        public boolean isAppendID()
        Returns:
        true if append application ID to IDs, otherwise false
      • setAppendID

        public void setAppendID​(boolean appendID)

        Sets a flag to include the WApplication's ID as part of its descendant components' IDs. This is used to determine if the application's components should include the application's ID in their own ID.

        Examples of where this could be useful include:

        • where there are multiple applications in a single view and there is a risk of IDs clashing; or
        • where the application ID is useful for separating IDs for external purposes such as implementing web analytics.
        Parameters:
        appendID - set true if append application ID to IDs
      • handleStepError

        public void handleStepError()

        This method is called when a wrong step error has occurred, for example as a result of the user using the browser's navigation controls.

        The method can be overridden to allow projects to handle the step error in a manner appropriate to their Application.

      • instance

        public static WApplication instance​(WComponent base)
        Returns the closest WApplication instance (ancestor component) from the given base component.
        Parameters:
        base - the component from which we start scanning up the tree for a WApplication instance
        Returns:
        the closest WApplication instance from the given base component
      • addJsUrl

        public WApplication.ApplicationResource addJsUrl​(String url)
        Add custom javaScript located at the specified URL to be used by the Application.
        Parameters:
        url - URL to a javaScript resource
        Returns:
        the application resource in which the URL details are held
      • addJsFile

        public WApplication.ApplicationResource addJsFile​(String fileName)
        Add custom JavaScript held as an internal resource to be used by the application.
        Parameters:
        fileName - the JavaScript file name
        Returns:
        the application resource in which the resource details are held
      • addJsResource

        public void addJsResource​(WApplication.ApplicationResource resource)
        Add a custom javaScript resource that is to be loaded and used by the application.
        Parameters:
        resource - the JavaScript resource
      • removeAllJsResources

        public void removeAllJsResources()
        Remove all custom JavaScript resources.
      • removeJsResource

        public void removeJsResource​(WApplication.ApplicationResource resource)
        Remove a custom JavaScript resource.
        Parameters:
        resource - the javaScript resource to remove
      • addCssUrl

        public WApplication.ApplicationResource addCssUrl​(String url)
        Add custom CSS located at the specified URL to be used by the Application.
        Parameters:
        url - URL to a CSS resource
        Returns:
        the application resource in which the URL details are held
      • addCssFile

        public WApplication.ApplicationResource addCssFile​(String fileName)
        Add custom CSS held as an internal resource to be used by the Application.
        Parameters:
        fileName - the CSS file name
        Returns:
        the application resource in which the resource details are held
      • addCssResource

        public void addCssResource​(WApplication.ApplicationResource resource)
        Add a custom CSS resource that will be loaded and used by this application.
        Parameters:
        resource - the CSS resource
      • removeAllCssResources

        public void removeAllCssResources()
        Remove all custom CSS resources.
      • removeCssResource

        public void removeCssResource​(WApplication.ApplicationResource resource)
        Remove a custom CSS resource.
        Parameters:
        resource - the CSS resource to remove
      • toString

        public String toString()
        Description copied from class: AbstractWComponent
        Creates a String representation of this component; usually for debugging purposes.
        Overrides:
        toString in class AbstractWComponent
        Returns:
        a String representation of this component for debugging purposes
      • getIcon

        public static String getIcon()
        Returns:
        the application icon URL
      • getUiVersionKey

        protected String getUiVersionKey()
        Projects can override this method if different versions of the same Application need to be registered by UIRegistry.

        Projects need to make sure the implementation of UIRegistry used by the project uses this key correctly. The default implementation of UIRegistry simply uses the class name returned by this method.

        It is also important to note that the serialization of the WComponent tree using AbstractWComponent.WComponentRef also relies on this version key.

        Returns:
        the key used for the version of the application.
      • getComponentModel

        protected WApplication.WApplicationModel getComponentModel()
        Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.
        Overrides:
        getComponentModel in class AbstractWComponent
        Returns:
        the effective component model
      • getOrCreateComponentModel

        protected WApplication.WApplicationModel getOrCreateComponentModel()
        Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.
        Overrides:
        getOrCreateComponentModel in class AbstractWComponent
        Returns:
        the model for this component