Class WContentLink

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

    public class WContentLink
    extends AbstractContainer
    implements Disableable

    WContentLink is a convenience class to configure a WLink to display content, such as a pdf, that is rendered by WContent. By default, the content is displayed in a new window.

    Be warned that this link does not post the entire form, as the client will opens the content directly via a "get" request. For situations where it is important to post the form, use a combination of WButton and WContent.

    WContentLink provides a number of defaults to minimise configuration:-

    Window Height
    600px
    Window Width
    800px
    Resizable
    true

    Below is an example of the code required to use WContentLink:-

     private final WContentLink contentLink = new WContentLink("link to content");
    
     public SampleConstructor()
     {
         ....
         add(contentLink);
         ....
     }
    
     protected void preparePaintComponent(Request request)
     {
         ....
         contentLink.setContentAccess(examplePdfContent);
         ....
     }
     

    WContentLink provides basic configuration options, but if more advanced configuration is required, then a WLink component and WContent component should be used instead. Below is an example of the code required to use a WLink in combination with WContent:-

     private final WLink link = new WLink();
     private final WContent content = new WContent();
    
     public SampleConstructor()
     {
         ....
         link.setText("link to content");
         link.setOpenNewWindow(true);
         link.setTargetWindowName("content");
         add(link);
         add(content);
         ....
     }
    
     protected void preparePaintComponent(Request request)
     {
         ....
         link.setUrl(content.getUrl());
         content.setContentAccess(examplePdfContent);
         ....
     }
     
    Since:
    1.0.0
    Author:
    Jonathan Austin
    See Also:
    Serialized Form
    • Constructor Detail

      • WContentLink

        public WContentLink()
        Construct the WContentLink.
      • WContentLink

        public WContentLink​(String aText)
        Creates a WContentLink with the given text.
        Parameters:
        aText - the link text.
      • WContentLink

        public WContentLink​(String aText,
                            char accessKey)
        Creates a WContentLink with the given text and access key.
        Parameters:
        aText - the link text.
        accessKey - the link access key.
    • Method Detail

      • isHidden

        public boolean isHidden()
        Indicates whether this component is hidden. Hidden components take part in event handling and painting, but are not visible on the client.
        Specified by:
        isHidden in interface WComponent
        Overrides:
        isHidden in class AbstractWComponent
        Returns:
        true if this component is hidden, false if displayed.
      • setHidden

        public void setHidden​(boolean flag)

        Sets the client visibility of this component. Hidden components take part in event handling and painting, but are not palpable on the client.

        Overrides:
        setHidden in class AbstractWComponent
        Parameters:
        flag - true for hidden, false for displayed.
      • isDisabled

        public boolean isDisabled()
        Indicates whether this link is disabled in the given context.
        Specified by:
        isDisabled in interface Disableable
        Returns:
        true if this link is disabled, otherwise false.
      • setDisabled

        public void setDisabled​(boolean disabled)
        Sets whether this link is disabled.
        Specified by:
        setDisabled in interface Disableable
        Parameters:
        disabled - if true, this link is disabled. If false, it is enabled.
      • getText

        public String getText()
        Returns:
        the text to be displayed on the link.
      • setText

        public void setText​(String text,
                            Serializable... args)
        Sets the text displayed on the link.
        Parameters:
        text - the link text, using MessageFormat syntax.
        args - optional arguments for the message format string.
      • isRenderAsButton

        public boolean isRenderAsButton()
        Indicates whether this link should render as a button.
        Returns:
        true if this link should render as a button, false for a hyperlink.
      • setRenderAsButton

        public void setRenderAsButton​(boolean renderAsButton)
        Sets whether this link should render as a button.
        Parameters:
        renderAsButton - true if this link should render as a button, false for a hyperlink.
      • getWindowAttrs

        public WLink.WindowAttributes getWindowAttrs()
        Retrieves the attributes for new windows which are opened.

        To change attributes for individual users, set a new WLink.WindowAttributes object for each user.

        Returns:
        the attributes for new windows.
      • setWindowAttrs

        public void setWindowAttrs​(WLink.WindowAttributes windowAttrs)
        Parameters:
        windowAttrs - the attributes for new windows which are opened.
      • getHeight

        @Deprecated
        public int getHeight()
        Deprecated.
        use getWindowAttrs() to access window attributes.
        Returns:
        The height of the window containing the content.
      • setHeight

        @Deprecated
        public void setHeight​(int height)
        Deprecated.
        use getWindowAttrs() to access window attributes.
        Parameters:
        height - The height of the window containing the content.
      • isResizable

        @Deprecated
        public boolean isResizable()
        Deprecated.
        use getWindowAttrs() to access window attributes.
        Returns:
        Returns true if the window is resizable.
      • setResizable

        @Deprecated
        public void setResizable​(boolean resizable)
        Deprecated.
        use getWindowAttrs() to access window attributes.
        Parameters:
        resizable - Should the window be resizable.
      • getWidth

        @Deprecated
        public int getWidth()
        Deprecated.
        use getWindowAttrs() to access window attributes.
        Returns:
        The width of the window containing the content.
      • setWidth

        @Deprecated
        public void setWidth​(int width)
        Deprecated.
        use getWindowAttrs() to access window attributes.
        Parameters:
        width - The width of the window containing the document content.
      • setContentAccess

        public void setContentAccess​(ContentAccess contentAccess)
        Supply this component with access to the document content to be displayed.
        Parameters:
        contentAccess - the ContentAccess which will supply the content.
      • getContentAccess

        public ContentAccess getContentAccess()
        Returns:
        the ContentAccess which will supply the content.
      • getCacheKey

        public String getCacheKey()
        Returns:
        the cacheKey
      • setCacheKey

        public void setCacheKey​(String cacheKey)
        Parameters:
        cacheKey - the cacheKey to set.
      • setDisplayMode

        public void setDisplayMode​(WContent.DisplayMode displayMode)
        Sets the content display mode. Note that the window attributes will be ignored if the mode is changed to something other than WContent.DisplayMode.OPEN_NEW_WINDOW.
        Parameters:
        displayMode - the content display mode to set.
      • 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.