com.ibm.workplace.wcm.api
Class WCM_JSR168RenderingContext

java.lang.Object
  extended bycom.ibm.workplace.wcm.api.WCM_RenderingContext
      extended bycom.ibm.workplace.wcm.api.WCM_JSR168RenderingContext
All Implemented Interfaces:
RenderingContext

public class WCM_JSR168RenderingContext
extends com.ibm.workplace.wcm.api.WCM_RenderingContext

Represents a rendering context.

A rendering context contains all the information required to render a renderable object. This includes information such as the path to the object to be rendered and any request parameters.

Here is an example of how to create a RenderingContext, adding to the context, and then using the context to render a piece of content:

 // Get the workspace
 Workspace workspace = Repository.getWorkspace("myUser", "myPassword");

 // Create the rendering context
 RenderingContext context =  workspace.createRenderingContext(portletRequestObj,
                                  portletResponseObj,
                                  new HashMap(),
                                  "http://localhost:9081/wcm",
                                  "connect");

 // Set the path to the content to be rendered
 context.setRenderedContent("/SiteA/SiteArea1/SiteArea1-1/myContent");

 // Get the rendered string
 String renderedContent = workspace.render(context);
 


Field Summary
static java.lang.String COPYRIGHT
          Copyright statement
 
Method Summary
 Content getContent()
          Returns the Content object that will be rendered by this RenderingContext.
 java.lang.String getPath()
          Returns the path to the object being rendered.
 java.lang.String getPrefix()
          Returns the prefix for all document URLs generated on rendering.
 java.lang.String getPresTemplateOverride()
          Returns the name of the PresentationTemplate to be used when rendering.
 Site getSite()
          Returns the Site object that is in this RenderingContext.
 SiteArea[] getSiteAreas()
          Returns an ordered array of SiteArea objects that are in the path to be rendered by this RenderingContext.
 java.lang.String getURL()
          Returns the URL to WCM and any request parameters, as according to the URL.
 java.lang.String getWcmServletPath()
          Returns the servlet path to be used - either the servlet path that has been set, or the servlet path from the request.
 java.lang.String getWcmWebAppPath()
          Returns the web app path to be used - either the WCM web app path that has been set using setWcmWebAppPath(String), or the path from the request.
 boolean isPresentationOverride()
          Returns true if a presentation template override has been specified; false otherwise.
 void setPrefix(java.lang.String p_prefix)
          Sets the prefix for all document URLs generated on rendering.
 void setPresentationTemplateOverride(java.lang.String p_presTemplateName)
          Sets the name of the presentation template to the string argument specified.
 void setRenderedContent(Content p_content, SiteArea p_siteArea)
          Sets the Content object to be rendered.
 void setRenderedContent(Site p_site)
          Sets the Site to be rendered.
 void setRenderedContent(SiteArea p_siteArea)
          Sets the SiteArea to be rendered.
 void setRenderedContent(java.lang.String p_path)
          Sets the full path of the Content to render.
 void setWcmServletPath(java.lang.String wcmServletPath)
          Sets the servlet path of the WCM servlet.
 void setWcmWebAppPath(java.lang.String wcmWebAppPath)
          Sets the path (including host) to the WCM web application.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
Copyright statement

See Also:
Constant Field Values
Method Detail

setPresentationTemplateOverride

public void setPresentationTemplateOverride(java.lang.String p_presTemplateName)
Sets the name of the presentation template to the string argument specified.

The argument to this method must be the name of the presentation template to use when rendering. The argument to this method will override any presentation template specified in the presentation-authoring template mapping of the Site or SiteArea.

Passing a null argument to this method will result in no presentation template override occurring. I.e. Rendering will behave as if this method had not been called.

Note: This method does not check whether the string argument is a valid PresentationTemplate in the repository.

Specified by:
setPresentationTemplateOverride in interface RenderingContext
Parameters:
p_presTemplateName - the presentation template name

setRenderedContent

public void setRenderedContent(java.lang.String p_path)
Sets the full path of the Content to render. This is of the form
/Site/SiteArea/SiteArea/Content

Note: This path must include the Content.

Specified by:
setRenderedContent in interface RenderingContext
Parameters:
p_path - the full path of the Content to render

setRenderedContent

public void setRenderedContent(Site p_site)
Sets the Site to be rendered.

If this method is used to specify what shall be rendered, then the default content of the Site argument will be rendered, if it has been set.

Specified by:
setRenderedContent in interface RenderingContext
Parameters:
p_site - the Site to be rendered

setRenderedContent

public void setRenderedContent(SiteArea p_siteArea)
Sets the SiteArea to be rendered.

If this method is used to specify what shall be rendered, then the default content of the SiteArea argument will be rendered, if it has been set.

Specified by:
setRenderedContent in interface RenderingContext
Parameters:
p_siteArea - the SiteArea to be rendered

setRenderedContent

public void setRenderedContent(Content p_content,
                               SiteArea p_siteArea)
Sets the Content object to be rendered.

Note: The Content specified must exist under the given SiteArea.

Specified by:
setRenderedContent in interface RenderingContext
Parameters:
p_content - the Content to render
p_siteArea - the SiteArea that the Content belongs to

setWcmWebAppPath

public void setWcmWebAppPath(java.lang.String wcmWebAppPath)
Sets the path (including host) to the WCM web application. This is of the form:

http://host[:port]/context_path

Specified by:
setWcmWebAppPath in interface RenderingContext
Parameters:
wcmWebAppPath - the path to the WCM web application

setWcmServletPath

public void setWcmServletPath(java.lang.String wcmServletPath)
Sets the servlet path of the WCM servlet.

Specified by:
setWcmServletPath in interface RenderingContext
Parameters:
wcmServletPath - the servlet path of the WCM servlet

getURL

public java.lang.String getURL()
Returns the URL to WCM and any request parameters, as according to the URL. The WCM URL is the part of the URL up until the path. That is:
getWcmWebAppPath() + getWcmServletPath() + getPath() +
 [?requestParamName1=requestParamValue1&...] == getURL()

Specified by:
getURL in interface RenderingContext
Returns:
the URL (including request parameters)

getPath

public java.lang.String getPath()
Returns the path to the object being rendered. This is everything after the servlet path, excluding any request parameters.

Returns null if the path could not be retrieved.

Specified by:
getPath in interface RenderingContext
Returns:
the path to the renderable object

isPresentationOverride

public boolean isPresentationOverride()
Returns true if a presentation template override has been specified; false otherwise.

For this method to return true setPresentationTemplateOverride() must have been called.

Specified by:
isPresentationOverride in interface RenderingContext
Returns:
true if the presentation template is being overridde; false otherwise

getPresTemplateOverride

public java.lang.String getPresTemplateOverride()
Returns the name of the PresentationTemplate to be used when rendering.

This method will return null if no presentation template override has been specified. This method will return null or an empty String if that is what was passed in to setPresentationTemplateOverride(String).

Use isPresentationOverride() before calling this method to ensure a presentation template has been specified.

Specified by:
getPresTemplateOverride in interface RenderingContext
Returns:
the name of the PresentationTemplate to use when rendering

setPrefix

public void setPrefix(java.lang.String p_prefix)
Sets the prefix for all document URLs generated on rendering.

A null argument to this method will be converted to an empty String and will have no effect on the document URLs generated on rendering.

Specified by:
setPrefix in interface RenderingContext
Parameters:
p_prefix - the String to prepend to all document URLs generated on rendering.

getPrefix

public java.lang.String getPrefix()
Returns the prefix for all document URLs generated on rendering.

Note: This method may return an empty String, but never null.

Specified by:
getPrefix in interface RenderingContext
Returns:
the prefix

getContent

public Content getContent()
Returns the Content object that will be rendered by this RenderingContext.

If a Site or SiteArea was specified as the argument to setRenderedContent(), this method will return the default Content of the relevant Site or SiteArea.

Note: This method will return null if the Content object could not be retrieved.

Specified by:
getContent in interface RenderingContext
Returns:
the Content object to render

getSite

public Site getSite()
Returns the Site object that is in this RenderingContext.

This method may still be called even if setRenderedContent(Site) was not the method used to set the object to be rendered. I.e. A Site object will still be returned even if this RenderingContext will not be rendering a Site.

Note: Returns null if no Site has been set or if the Site object could not be retrieved.

Specified by:
getSite in interface RenderingContext
Returns:
the Site object

getSiteAreas

public SiteArea[] getSiteAreas()
Returns an ordered array of SiteArea objects that are in the path to be rendered by this RenderingContext.

The order of the SiteArea objects in this array matches the order of the SiteArea objects in the Site Area hierarchy.

Specified by:
getSiteAreas in interface RenderingContext
Returns:
an ordered array of SiteArea objects

getWcmWebAppPath

public java.lang.String getWcmWebAppPath()
Returns the web app path to be used - either the WCM web app path that has been set using setWcmWebAppPath(String), or the path from the request. This includes from the protocol up to and including the context path.

Specified by:
getWcmWebAppPath in interface RenderingContext
Returns:
the web app path that will be used when rendering

getWcmServletPath

public java.lang.String getWcmServletPath()
Returns the servlet path to be used - either the servlet path that has been set, or the servlet path from the request.

Specified by:
getWcmServletPath in interface RenderingContext
Returns:
the servlet path that will be used when rendering