Class WContent
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.WContent
-
- All Implemented Interfaces:
Targetable,WComponent,WebComponent,Serializable
public class WContent extends AbstractWComponent implements Targetable
This wcomponent enables the display of arbitrary document content from a WComponent application. This component does not by default display anything until the
display()method is called. It then causes the browser to access the content through the WContentHelperServlet.By default, the browser will display the content in a new window, but the
setDisplayMode(DisplayMode)method can be used to display the content inline or prompt the user to save the content to a file.- Since:
- 1.0.0
- Author:
- Martin Shevchenko
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWContent.ContentModelHolds the extrinsic state information of a WContent.static classWContent.DisplayModeAn enumeration of how the content should be provided to the user.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
-
Field Summary
Fields Modifier and Type Field Description static StringURL_CONTENT_MODE_PARAMETER_KEYThis magic parameter is a work-around to the loading indicator becoming "stuck" in certain browsers.-
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 WContent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafterPaint(RenderContext renderContext)Subclasses may override this method to output content after the component has been painted.voiddisplay()Next time this component is painted, it will output the appropriate script to open a new browser window to display the content.StringgetCacheKey()protected WContent.ContentModelgetComponentModel()Returns the effective component model for this component.ContentAccessgetContentAccess()WContent.DisplayModegetDisplayMode()StringgetHeight()protected WContent.ContentModelgetOrCreateComponentModel()Retrieves the model for this component so that it can be modified.StringgetTargetId()Implementation of the Targetable interface.StringgetUrl()Retrieves a dynamic URL which this targetable component can be accessed from.StringgetWidth()voidhandleRequest(Request request)Override handleRequest in order to perform processing specific to this component.booleanisDisplayRequested()Indicates whether the content should be displayed in the given context.booleanisResizable()protected WContent.ContentModelnewComponentModel()Creates a new ComponentModel appropriate for this component.voidsetCacheKey(String cacheKey)voidsetContentAccess(ContentAccess contentAccess)Supply this component with access to the document content to be displayed.voidsetDisplayMode(WContent.DisplayMode displayMode)Sets the content display mode.voidsetHeight(String height)voidsetResizable(boolean resizable)voidsetWidth(String width)StringtoString()Creates a String representation of this component; usually for debugging purposes.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWComponent
addHtmlClass, addHtmlClass, addNotify, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, paintComponent, preparePaint, preparePaintComponent, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHidden, 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, hasTabIndex, invokeLater, isDefaultState, isHidden, 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
-
-
-
-
Field Detail
-
URL_CONTENT_MODE_PARAMETER_KEY
public static final String URL_CONTENT_MODE_PARAMETER_KEY
This magic parameter is a work-around to the loading indicator becoming "stuck" in certain browsers. It is also used by the static resource handler to set the correct headers- See Also:
- Constant Field Values
-
-
Method Detail
-
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.
-
display
public void display()
Next time this component is painted, it will output the appropriate script to open a new browser window to display the content.
-
getHeight
public String getHeight()
- Returns:
- The height of the window containing the document content. Default is 600px.
-
setHeight
public void setHeight(String height)
- Parameters:
height- The height of the window containing the document content.
-
isResizable
public boolean isResizable()
- Returns:
- Returns True if the window is resizable.
-
setResizable
public void setResizable(boolean resizable)
- Parameters:
resizable- Should the window be resizable.
-
getWidth
public String getWidth()
- Returns:
- The width of the window containing the document content. Default is 800px.
-
setWidth
public void setWidth(String width)
- Parameters:
width- The width of the window containing the document content.
-
getDisplayMode
public WContent.DisplayMode getDisplayMode()
- Returns:
- Returns the displayMode.
-
setDisplayMode
public void setDisplayMode(WContent.DisplayMode displayMode)
Sets the content display mode. The default displayMode isWContent.DisplayMode.OPEN_NEW_WINDOW.- Parameters:
displayMode- The displayMode to set.
-
getCacheKey
public String getCacheKey()
- Returns:
- the cacheKey
-
setCacheKey
public void setCacheKey(String cacheKey)
- Parameters:
cacheKey- the cacheKey to set.
-
isDisplayRequested
public boolean isDisplayRequested()
Indicates whether the content should be displayed in the given context.- Returns:
- true if the content should be displayed, otherwise false.
-
getTargetId
public String getTargetId()
Implementation of the Targetable interface.- Specified by:
getTargetIdin interfaceTargetable- Returns:
- the target id for this targetable.
-
getUrl
public String getUrl()
Retrieves a dynamic URL which this targetable component can be accessed from.- Returns:
- the URL to access this targetable component.
-
handleRequest
public void handleRequest(Request request)
Override handleRequest in order to perform processing specific to this component.
When the new browser window for the document content is opened, it will make another request to fetch the content. It is that situation we are trying to detect and handle here.
- Specified by:
handleRequestin interfaceWComponent- Overrides:
handleRequestin classAbstractWComponent- Parameters:
request- the request being responded to.
-
afterPaint
protected void afterPaint(RenderContext renderContext)
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:
afterPaintin classAbstractWComponent- Parameters:
renderContext- the context to render to.
-
toString
public String toString()
Description copied from class:AbstractWComponentCreates a String representation of this component; usually for debugging purposes.- Overrides:
toStringin classAbstractWComponent- Returns:
- a String representation of this component, for debugging purposes.
-
newComponentModel
protected WContent.ContentModel newComponentModel()
Creates a new ComponentModel appropriate for this component.- Overrides:
newComponentModelin classAbstractWComponent- Returns:
- a new ContentModel.
-
getComponentModel
protected WContent.ContentModel 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:
getComponentModelin classAbstractWComponent- Returns:
- the effective component model
-
getOrCreateComponentModel
protected WContent.ContentModel 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:
getOrCreateComponentModelin classAbstractWComponent- Returns:
- the model for this component
-
-