Class WContentLink
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.AbstractContainer
-
- com.github.bordertech.wcomponents.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 byWContent
. 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
andWContent
.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 andWContent
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
-
Field Summary
-
Fields inherited from interface com.github.bordertech.wcomponents.WComponent
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
-
-
Constructor Summary
Constructors Constructor Description WContentLink()
Construct the WContentLink.WContentLink(String aText)
Creates a WContentLink with the given text.WContentLink(String aText, char accessKey)
Creates a WContentLink with the given text and access key.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
getCacheKey()
ContentAccess
getContentAccess()
int
getHeight()
Deprecated.usegetWindowAttrs()
to access window attributes.String
getText()
int
getWidth()
Deprecated.usegetWindowAttrs()
to access window attributes.WLink.WindowAttributes
getWindowAttrs()
Retrieves the attributes for new windows which are opened.boolean
isDisabled()
Indicates whether this link is disabled in the given context.boolean
isHidden()
Indicates whether this component is hidden.boolean
isRenderAsButton()
Indicates whether this link should render as a button.boolean
isResizable()
Deprecated.usegetWindowAttrs()
to access window attributes.void
setCacheKey(String cacheKey)
void
setContentAccess(ContentAccess contentAccess)
Supply this component with access to the document content to be displayed.void
setDisabled(boolean disabled)
Sets whether this link is disabled.void
setDisplayMode(WContent.DisplayMode displayMode)
Sets the content display mode.void
setHeight(int height)
Deprecated.usegetWindowAttrs()
to access window attributes.void
setHidden(boolean flag)
Sets the client visibility of this component.void
setRenderAsButton(boolean renderAsButton)
Sets whether this link should render as a button.void
setResizable(boolean resizable)
Deprecated.usegetWindowAttrs()
to access window attributes.void
setText(String text, Serializable... args)
Sets the text displayed on the link.void
setWidth(int width)
Deprecated.usegetWindowAttrs()
to access window attributes.void
setWindowAttrs(WLink.WindowAttributes windowAttrs)
String
toString()
Creates a String representation of this component; usually for debugging purposes.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractContainer
getChildAt, getChildCount, getChildren, getIndexOfChild
-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWComponent
addHtmlClass, addHtmlClass, addNotify, afterPaint, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getComponentModel, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getOrCreateComponentModel, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, handleRequest, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, newComponentModel, paint, paintComponent, preparePaint, preparePaintComponent, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showErrorIndicatorsForComponent, showWarningIndicators, showWarningIndicatorsForComponent, tidyUpUIContext, tidyUpUIContextForTree, validate, validateComponent, writeReplace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.bordertech.wcomponents.WComponent
addHtmlClass, addHtmlClass, forward, getAccessibleText, getAttribute, getBaseUrl, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getTabIndex, getTag, getToolTip, handleRequest, hasTabIndex, invokeLater, isDefaultState, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
-
-
-
-
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 interfaceWComponent
- Overrides:
isHidden
in classAbstractWComponent
- 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 classAbstractWComponent
- 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 interfaceDisableable
- 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 interfaceDisableable
- 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, usingMessageFormat
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.usegetWindowAttrs()
to access window attributes.- Returns:
- The height of the window containing the content.
-
setHeight
@Deprecated public void setHeight(int height)
Deprecated.usegetWindowAttrs()
to access window attributes.- Parameters:
height
- The height of the window containing the content.
-
isResizable
@Deprecated public boolean isResizable()
Deprecated.usegetWindowAttrs()
to access window attributes.- Returns:
- Returns true if the window is resizable.
-
setResizable
@Deprecated public void setResizable(boolean resizable)
Deprecated.usegetWindowAttrs()
to access window attributes.- Parameters:
resizable
- Should the window be resizable.
-
getWidth
@Deprecated public int getWidth()
Deprecated.usegetWindowAttrs()
to access window attributes.- Returns:
- The width of the window containing the content.
-
setWidth
@Deprecated public void setWidth(int width)
Deprecated.usegetWindowAttrs()
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 thanWContent.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 classAbstractWComponent
- Returns:
- a String representation of this component, for debugging purposes.
-
-