Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.ibm.workplace.wcm.api
Interface RenderingContext

All Superinterfaces:
  java.lang.Cloneable

    public interface RenderingContext

extends java.lang.Cloneable

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(servletRequestObj,
                                      servletResponseObj,
                                      new HashMap(),
                                      "http://[HOSTNAME]:[PORT]/[CONTEXT]",
                                      "connect");

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

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

Method Summary
`RenderingContext` | `clone()` Cloning a RenderingContext will copy all member variables on the current instance, this includes request, response, web app URL, servlet path, prefix, presentation template override, request parameters, and rendered item.
`SiteArea[]` | `getAllSiteAreas()` Returns an ordered array of `SiteArea` objects that are in the path to be rendered by this `RenderingContext`.
`Content` | `getContent()` Returns the `Content` object that will be rendered by this `RenderingContext`.
`DocumentId` | `getCurrentResultId()` Returns the current result `DocumentId` value.
`DocumentLibrary` | `getLibrary()` Returns the `DocumentLibrary` of the object being rendered.
`java.lang.String` | `getLibraryRelativePath()` Returns the path relative to the library of the object being rendered.
`java.util.Locale` | `getLocale()` Retrieve the `Locale` being used to render the current page.
`java.lang.String` | `getPath()` Returns the path to the object being rendered.
`java.lang.String` | `getPath(boolean includeLib)` Returns the path to the object being rendered.
`java.lang.String` | `getPathInfo()` Retrieve the path of the current rendering context
`java.lang.String` | `getPrefix()` Returns the prefix for all document URLs generated on rendering.
`java.lang.String` | `getPresTemplateOverride()` Returns the name path of the `PresentationTemplate` to be used when rendering.
`DocumentId<Project>` | `getProjectId()` Returns the `DocumentId` of the `Project` associated with this `RenderingContext`
`TemplatedDocument` | `getRenderedItem()` Returns the `TemplatedDocument` object that will be rendered by this `RenderingContext`.
`java.util.Map` | `getRequestParameters()` Returns the current request parameters used by this `RenderingContext`.
`Site` | `getSite()` Deprecated. No replacement. `Site` is not required in Web sites created using the current version of IBM Web Content Manager. The method is retained for compatibility with Web sites migrated from pre 7.0 versions of IBM Web Content Manager. Use `getAllSiteAreas()` to get all level site areas.
`SiteArea[]` | `getSiteAreas()` Deprecated. No replacement. The method is retained for compatibility with Web sites migrated from pre 7.0 versions of IBM Web Content Manager. Use `getAllSiteAreas()` to get all level site areas.
`java.lang.String` | `getURL()` Returns the URL to WCM and any request parameters.
`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` | `hasProject()` Indicates if this RenderingContext has a `Project` registered
`boolean` | `isGenerateContextualLinks()` Returns whether to generate contextual (a.k.a.
`boolean` | `isInEditMode()` Indicates if the portal page is rendering in View Mode or Edit Mode
`boolean` | `isPresentationOverride()` Returns `true` if a presentation template override has been specified; `false` otherwise.
`void` | `removeProject()` remove any Project from this `RenderingContext`.
`void` | `setGenerateContextualLinks(boolean contextualLinks)` Sets whether to generate contextual (a.k.a.
`void` | `setPrefix(java.lang.String prefix)` Sets the prefix for all document URLs generated on rendering.
`void` | `setPresentationTemplateOverride(java.lang.String presTemplateName)` Sets the name path of the presentation template to the string argument specified.
`void` | `setProject(Project project)` Set a `Project` within this `RenderingContext`.
`void` | `setProject(java.lang.String projectName)` Set a `Project` by name in this `RenderingContext`.
`void` | `setRenderedContent(Content content, SiteArea siteArea)` Sets the `Content` object to be rendered.
`void` | `setRenderedContent(Site site)` Deprecated. Use setRenderedContent(SiteArea)
`void` | `setRenderedContent(SiteArea siteArea)` Sets the `SiteArea` to be rendered.
`void` | `setRenderedContent(java.lang.String path)` Sets the full path of the `Content` to render.
`void` | `setRequestParameters(java.util.Map requestParameters)` Sets the request parameters to be used by this `RenderingContext` while rendering.
`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.

Method Detail

### getURL

    java.lang.String getURL()

  Returns the URL to WCM and any request parameters. That is:

      getWcmWebAppPath() + getWcmServletPath() + getPath() +
       [?requestParamName1=requestParamValue1&...] == getURL()

  Returns:
    the URL (including request parameters)

### getPath

    java.lang.String getPath()

  Returns the path to the object being rendered. This is everything after the servlet path, excluding any request parameters. May not include the library in the path returned.

  Returns `null` if the path could not be retrieved.

  Returns:
    the path to the renderable object

### getPath

    java.lang.String getPath(boolean includeLib)

  Returns the path to the object being rendered. This is everything after the servlet path, excluding any request parameters. Will include the library when passed true. Will not include the library when passed false

  Returns `null` if the path could not be retrieved.

  Parameters:
    `includeLib` - `boolean` if true the path will include the library if false it will not.
  Returns:
    the path to the renderable object

### isPresentationOverride

    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.

  Returns:
    `true` if the presentation template is being overridden; `false` otherwise

### setPresentationTemplateOverride

    void setPresentationTemplateOverride(java.lang.String presTemplateName)

  Sets the name path of the presentation template to the string argument specified. The name path format is libraryName/presentationTemplateName.

  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.

  Parameters:
    `presTemplateName` - the presentation template name path

### getPresTemplateOverride

    java.lang.String getPresTemplateOverride()

  Returns the name path of the `PresentationTemplate` to be used when rendering. The name path format is libraryName/presentationTemplateName.

  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.

  Returns:
    the name path of the `PresentationTemplate` to use when rendering

### setPrefix

    void setPrefix(java.lang.String 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.

  Parameters:
    `prefix` - the `String` to prepend to all document URLs generated on rendering.

### getPrefix

    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`.

  Returns:
    the prefix

### getRenderedItem

    TemplatedDocument getRenderedItem()

  Returns the `TemplatedDocument` 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`, unless the `SiteFrameworkContainer.RenderingBehaviour` is `RENDER_DIRECTLY`. In the case that `SiteFrameworkContainer.RenderingBehaviour` is `RENDER_DIRECTLY`, the `TemplatedDocument` object that will be returned is the `Site` or `SiteArea` itself.

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

  Returns:
    the `TemplatedDocument` object to render
  Since:
    8.0 (This is new in 8.0, since `SiteFrameworkContainer.RenderingBehaviour` is new in 8.0)

### getContent

    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.

  Since 8.0, this will return `null` if the rendered item has `SiteFrameworkContainer.RenderingBehaviour` set as `RENDER_DIRECTLY`. For this reason, from 8.0 onwards it is recommended to use `getRenderedItem()` rather than this method.

  Returns:
    the `Content` object to render

### getSite

    @Deprecated
    Site getSite()

  Deprecated. No replacement. `Site` is not required in Web sites created using the current version of IBM Web Content Manager. The method is retained for compatibility with Web sites migrated from pre 7.0 versions of IBM Web Content Manager. Use `getAllSiteAreas()` to get all level site areas.

  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.

  Returns:
    the `Site` object

### getSiteAreas

    @Deprecated
    SiteArea[] getSiteAreas()

  Deprecated. No replacement. The method is retained for compatibility with Web sites migrated from pre 7.0 versions of IBM Web Content Manager. Use `getAllSiteAreas()` to get all level site areas.

  Returns an ordered array of `SiteArea` objects that are in the path to be rendered by this `RenderingContext`. The `Site` will not be included.

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

  Returns:
    an ordered array of `SiteArea` objects

### getAllSiteAreas

    SiteArea[] getAllSiteAreas()

  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.

  Returns:
    an ordered array of `SiteArea` objects

### setRenderedContent

    void setRenderedContent(java.lang.String path)

  Sets the full path of the `Content` to render. This is of the form

      /Library/Site/SiteArea/SiteArea/Content

  Note: This path must include the `Content`, unless the `SiteArea`'s `SiteFrameworkContainer.RenderingBehaviour` is `RENDER_DIRECTLY`.

  Parameters:
    `path` - the full path of the `Content` or `SiteArea` to render

### setRenderedContent

    @Deprecated
    void setRenderedContent(Site site)

  Deprecated. Use setRenderedContent(SiteArea)

  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.

  Parameters:
    `site` - the `Site` to be rendered

### setRenderedContent

    void setRenderedContent(SiteArea siteArea)

  Sets the `SiteArea` to be rendered.

  If this method is used to specify what shall be rendered, then the `SiteArea` will be rendered, in the manner according to its `SiteFrameworkContainer.RenderingBehaviour`

  Parameters:
    `siteArea` - the `SiteArea` to be rendered

### setRenderedContent

    void setRenderedContent(Content content,
                            SiteArea siteArea)

  Sets the `Content` object to be rendered.

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

  Parameters:
    `content` - the `Content` to render
    `siteArea` - the `SiteArea` that the `Content` belongs to

### setWcmWebAppPath

    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`

  Parameters:
    `wcmWebAppPath` - the path to the WCM web application

### setWcmServletPath

    void setWcmServletPath(java.lang.String wcmServletPath)

  Sets the servlet path of the WCM servlet.

  Parameters:
    `wcmServletPath` - the servlet path of the WCM servlet

### getWcmWebAppPath

    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.

  Returns:
    the web app path that will be used when rendering

### getWcmServletPath

    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.

  Returns:
    the servlet path that will be used when rendering

### setRequestParameters

    void setRequestParameters(java.util.Map requestParameters)

  Sets the request parameters to be used by this `RenderingContext` while rendering. The parameters of this Map will override the existing parameters of the request.

  Parameters:
    `requestParameters` - the request parameters for the request as a map of name=single-value parameters.

### getRequestParameters

    java.util.Map getRequestParameters()

  Returns the current request parameters used by this `RenderingContext`. This will be a copy of the actual map. Changes made to the returned map will not change the parameters being used in this `RenderingContext`.

  Returns:
    the request parameters map of name=single-value parameters

### getCurrentResultId

    DocumentId getCurrentResultId()

  Returns the current result `DocumentId` value. This method will only return a value when invoked within a Menu, Navigator, Search, Personalization or Taxonomy component. Otherwise, `null` will be returned.

  Returns:
    the current result `DocumentId` or `null` if no result value currently exists.

### isGenerateContextualLinks

    boolean isGenerateContextualLinks()

  Returns whether to generate contextual (a.k.a. Piece of Content or PoC) links if possible. A contextual link will lead to the portlet associated with the linked content.

  Returns:
    boolean

### setGenerateContextualLinks

    void setGenerateContextualLinks(boolean contextualLinks)

  Sets whether to generate contextual (a.k.a. Piece of Content or PoC) links if possible. A contextual link will lead to the portlet associated with the linked content.

  Parameters:
    `contextualLinks` - true to create contextual links

### getLibraryRelativePath

    java.lang.String getLibraryRelativePath()

  Returns the path relative to the library of the object being rendered. That is, the path starting at the Site name.

  Returns `null` if the path could not be retrieved.

  Returns:
    the path relative to the library of the object being rendered.

### getLibrary

    DocumentLibrary getLibrary()

  Returns the `DocumentLibrary` of the object being rendered.

  Returns `null` if the `DocumentLibrary` could not be retrieved.

  Returns:
    the `DocumentLibrary` of the object being rendered.

### getPathInfo

    java.lang.String getPathInfo()

  Retrieve the path of the current rendering context

  Returns:
    the path of the current rendering context

### getLocale

    java.util.Locale getLocale()

  Retrieve the `Locale` being used to render the current page.

  Returns:
    the `Locale` being used to render the current page.

### setProject

    void setProject(java.lang.String projectName)
                    throws DocumentNotFoundException

  Set a `Project` by name in this `RenderingContext`. If the projectName parameter is null, or a corresponding project for the name cannot be found, a DocumentNotFoundException will be thrown.

  Parameters:
    `projectName` - the name of the project to set
  Throws:
    `DocumentNotFoundException` - if the projectName parameter is null, or a corresponding project for the name cannot be found.

### setProject

    void setProject(Project project)
                    throws DocumentNotFoundException

  Set a `Project` within this `RenderingContext`. If the project parameter is null, a DocumentNotFoundException is thrown.

  Parameters:
    `project` - the project to set in this `RenderingContext`.
  Throws:
    `DocumentNotFoundException` - if the project parameter is null

### removeProject

    void removeProject()

  remove any Project from this `RenderingContext`.

### isInEditMode

    boolean isInEditMode()

  Indicates if the portal page is rendering in View Mode or Edit Mode

  Returns:
    true if the portal page is rendering in Edit Mode, false otherwise

### hasProject

    boolean hasProject()

  Indicates if this RenderingContext has a `Project` registered

  Returns:
    true if a `Project` is registered, false otherwise

### getProjectId

    DocumentId<Project> getProjectId()

  Returns the `DocumentId` of the `Project` associated with this `RenderingContext`

  Returns:
    the `DocumentId` of the `Project` associated with this `RenderingContext`

### clone

    RenderingContext clone()

  Cloning a RenderingContext will copy all member variables on the current instance, this includes request, response, web app URL, servlet path, prefix, presentation template override, request parameters, and rendered item.

  Returns:
    a cloned Rendering Context

Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD