Class WWindow

  • All Implemented Interfaces:
    Container, WComponent, WebComponent, Serializable

    public class WWindow
    extends AbstractWComponent
    implements Container
    This component enables a pop up browser window with interactive wcomponent content. Be warned that pop up windows can cause workflow headaches as you can't control where the user goes. Eg. They may not close a pop up window before going back to the parent window. Later on they may choose to continue working in the pop up window, breaking the intended flow of the application.
    Since:
    1.0.0
    Author:
    Martin Shevchenko, Jonathan Austin
    See Also:
    Serialized Form
    • Field Detail

      • WWINDOW_REQUEST_PARAM_KEY

        public static final String WWINDOW_REQUEST_PARAM_KEY
        Request parameter key for a wwindow.
        See Also:
        Constant Field Values
      • INACTIVE_STATE

        public static final int INACTIVE_STATE
        This is the "normal" state for the Window component when it's being processed as part of the parent window.
        See Also:
        Constant Field Values
      • DISPLAY_STATE

        public static final int DISPLAY_STATE
        The component is in this state when a request has been made to display the window. The necessary mark-up to open the window will be rendered in this mode.
        See Also:
        Constant Field Values
      • ACTIVE_STATE

        public static final int ACTIVE_STATE
        This state is when the window is open and the initial render of the content is complete.
        See Also:
        Constant Field Values
    • Constructor Detail

      • WWindow

        public WWindow()
        Creates a new Window.
      • WWindow

        public WWindow​(WComponent content)
        Creates a new Window containing the specified content.
        Parameters:
        content - the window content.
    • Method Detail

      • setContent

        public void setContent​(WComponent content)
        Set the WComponent that will handle the content for this pop up window.
        Parameters:
        content - the window content.
      • getContent

        public WComponent getContent()
        Returns:
        the component which is the content for this window.
      • getTitle

        public String getTitle()
        Returns:
        the window title.
      • setTitle

        public void setTitle​(String title)
        Sets the window title.
        Parameters:
        title - The title to set.
      • display

        public void display()
        Signals that the pop up window should be opened in the given context.
      • getHeight

        public int getHeight()
        Returns:
        The height of the window. Default is 600px.
      • setHeight

        public void setHeight​(int height)
        Sets the window height.
        Parameters:
        height - The height of the window.
      • getWidth

        public int getWidth()
        Returns:
        The width of the window. Default is 800px.
      • setWidth

        public void setWidth​(int width)
        Sets the window width.
        Parameters:
        width - The width of the window.
      • getTop

        public int getTop()
        Returns:
        the y-coordinate of the window.
      • setTop

        public void setTop​(int top)
        Sets the y-coordinate of the window.
        Parameters:
        top - The y-coordinate of the window, or -1 for default.
      • getLeft

        public int getLeft()
        Returns:
        the x-coordinate of the window.
      • setLeft

        public void setLeft​(int left)
        Sets the x-coordinate of the window.
        Parameters:
        left - The x-coordinate of the window, or -1 for default.
      • isShowMenuBar

        public boolean isShowMenuBar()
        Returns:
        true the browser menubar should be shown.
      • setShowMenuBar

        public void setShowMenuBar​(boolean showMenuBar)
        Sets whether the browser menubar should be shown. It is hidden by default.
        Parameters:
        showMenuBar - The showMenuBar to set.
      • isShowToolbar

        public boolean isShowToolbar()
        Returns:
        true if the browser toolbar should be shown.
      • setShowToolbar

        public void setShowToolbar​(boolean showToolbar)
        Sets whether the browser toolbar should be shown. It is hidden by default.
        Parameters:
        showToolbar - The showToolbar to set.
      • isShowLocation

        public boolean isShowLocation()
        Returns:
        true if the browser location bar should be shown.
      • setShowLocation

        public void setShowLocation​(boolean showLocation)
        Sets whether the browser location bar should be shown. It is hidden by default.
        Parameters:
        showLocation - The showLocation to set.
      • isShowStatus

        public boolean isShowStatus()
        Returns:
        true if the browser status bar should be shown.
      • setShowStatus

        public void setShowStatus​(boolean showStatus)
        Sets whether the browser status bar should be shown. It is hidden by default.
        Parameters:
        showStatus - The showStatus to set.
      • isResizable

        public boolean isResizable()
        Returns:
        true if the window is resizable.
      • setResizable

        public void setResizable​(boolean resizable)
        Sets whether the window is resizable.
        Parameters:
        resizable - true if the window should be resizable, false if not.
      • isScrollable

        public boolean isScrollable()
        Returns:
        true if the window is scrollable.
      • setScrollable

        public void setScrollable​(boolean scrollable)
        Sets whether the window should have a scroll bar.
        Parameters:
        scrollable - true if the window should have a scroll bar, false if not.
      • getState

        public int getState()
        Retrieves the current state of the window.
        Returns:
        the current state of this window.
      • setState

        protected void setState​(int state)
        Sets the current state of this component.
        Parameters:
        state - the window state to set.
      • getUrl

        public String getUrl()
        Returns a dynamic URL that this wwindow component can be accessed from.
        Returns:
        the URL to access this wwindow component.
      • handleRequest

        public void handleRequest​(Request request)
        Override handleRequest in order to perform processing specific to this component.
        Specified by:
        handleRequest in interface WComponent
        Overrides:
        handleRequest in class AbstractWComponent
        Parameters:
        request - the request being responded to.
      • invokeLaters

        protected void invokeLaters()
        When the window is targetted, we need to run the "laters". If we don't do this, they will not run because a targetted request bypasses the root component that would normally have run them.
        Overrides:
        invokeLaters in class AbstractWComponent
      • preparePaintComponent

        protected void preparePaintComponent​(Request request)
        Override preparePaintComponent to clear the scratch map before the window content is being painted.
        Overrides:
        preparePaintComponent in class AbstractWComponent
        Parameters:
        request - the request being responded to.
      • paintComponent

        protected void paintComponent​(RenderContext renderContext)
        Override paintComponent in order to paint the window or its content, depending on the window state.
        Overrides:
        paintComponent in class AbstractWComponent
        Parameters:
        renderContext - the RenderContext to send the output to.
      • afterPaint

        protected void afterPaint​(RenderContext renderContext)
        Description copied from class: AbstractWComponent
        Subclasses may override this method to output content after the component has been painted. When overriding this method, it is good practice to call the superclass implementation before emitting any additional content.
        Overrides:
        afterPaint in class AbstractWComponent
        Parameters:
        renderContext - the context to render to.
      • showWindow

        protected void showWindow​(RenderContext renderContext)
        Emits the mark-up which pops up the window.
        Parameters:
        renderContext - the RenderContext to send the output to.
      • isTargeted

        protected boolean isTargeted()
        Returns:
        the current step counter.
      • setTargeted

        protected void setTargeted​(boolean targeted)
        Parameters:
        targeted - true if targeted
      • getStep

        public int getStep()
        Retrieves the current step counter. This method should only ever be used by internal code.
        Returns:
        the current step counter.
      • setStep

        public void setStep​(int step)
        Sets the current step counter. This method should only ever be used by internal code.
        Parameters:
        step - the step to set.
      • getChildCount

        public int getChildCount()
        Specified by:
        getChildCount in interface Container
        Returns:
        the number of child components currently contained within this component.
      • getChildAt

        public WComponent getChildAt​(int index)
        Retrieves a child component by its index.
        Specified by:
        getChildAt in interface Container
        Parameters:
        index - the index of the child component to be retrieved.
        Returns:
        the child component at the given index.
      • getChildren

        public List<WComponent> getChildren()
        Retrieves a list of this Container's.
        Specified by:
        getChildren in interface Container
        Returns:
        an immutable list of this Container.
      • getIndexOfChild

        public int getIndexOfChild​(WComponent childComponent)
        Retrieves the index of the given child.
        Specified by:
        getIndexOfChild in interface Container
        Parameters:
        childComponent - the child component to retrieve the index for.
        Returns:
        the index of the given child component, or -1 if the component is not a child of this component.
      • 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.
      • getComponentModel

        protected WWindow.WindowModel 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 WWindow.WindowModel 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