Web Content Manager JSP tags | HCL Digital Experience
You use HCL Web Content Manager JSP tags with the Web Content Manager API to pull Web Content Manager content and components into external JSP applications.
<%@taglib uri="/WEB-INF/tld/wcm.tld" prefix="wcm" %>
A dynamic context path value can be defined by adding a token to the context path that corresponds to a key and value pair to the Web Content Manager configuration service environment provider. When this key is used as the token in the jsp value field, it is replaced dynamically at render time. For example, my.custom.key;myfile where my.custom.key is a constant within the Web Content Manager configuration service.
The setExplicitContext and setContext tags are not required when you render a JSP file with a JSP Component. They are only required when directly accessing a JSP file.
JSP files that are referenced by Web Content Manager are reloaded once every 10 seconds. If you update a JSP file, you might need to wait for it to be reloaded before your changes are displayed.
InitWorkspace tag
- Sets the Web Content Manager workspace as a local variable called wcmWorkspace.
- Sets the Web Content Manager workspace on the pageContext as a parameter with key com.ibm.workplace.wcm.api.Workspace.WCM_WORKSPACE_KEY.
- Sets the Web Content Manager RenderingContext on the request as a parameter with key Workspace.WCM_RENDERINGCONTEXT_KEY
<wcm:initworkspace username=" " password=" " user=" " >
[Error Message]
</wcm:initworkspace>
Parameter | Details |
---|---|
username | The user name of a valid Web Content Manager user. |
user | This parameter is used to specify a java.security.Principal object instead of the user name. |
password | The password for the valid Web Content Manager user name or user. |
<%@ taglib uri="/WEB-INF/tld/wcm.tld" prefix="wcm"%>
<%@ page import="com.ibm.workplace.wcm.api.*" %>
<p><wcm:initworkspace>login fail</wcm:initworkspace>
<%
// Get the workspace for use
Workspace workspace = (Workspace) pageContext.getAttribute(Workspace.WCM_WORKSPACE_KEY);
// Get the WCM rendering context for use
RenderingContext renderingContext = (RenderingContext) request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);
%>
Explicit context tag
This tag sets the path to your Web Content Manager server. This tag is not required in JSP that is displayed by using a JSP component.
<wcm:setExplicitContext wcmWebAppPath=" " wcmServletPath=" " path=" "
requestParameters=" " prefix=" " project=" " >
[Error Message]
</wcm:setExplicitContext>
Parameter | Details |
---|---|
wcmWebAppPath | The URL up to the web application. For example, http://localhost:10039/wps/wcm |
wcmServletPath | The servlet path to the Web Content Manager
servlet. For example, /connect |
path | The path to the content and site areas. For example, /Site Area A/ Site Area B/Content C |
requestParameters | You specify java Map request parameters to set in the context. These
parameters can be used by menu components that are rendered through the JSP that use a query
string. See Writing links to web content for details of request parameters that can be used when you reference web content items. |
project | The name of the project to set in the context. If the corresponding project cannot be found, it is ignored and an error is logged. An empty string is used to clear any project that is previously set in the context. |
Developers can add insert context tags at any place in the page and it changes the context for the rest of the page execution, but the tags cannot be nested.
Context retrieval tag
Sets the context given the location of a path string. This tag is not required in JSP that is displayed by using a JSP component.
<wcm:setContext location=" " wcmWebAppPath=" " wcmServletPath=" " param=" " project=" " defaultPath=" " >
[Error Message]
</wcm:setContext>
Parameter | Details |
---|---|
location | This parameter sets the context of the location of a path string. Either
|
wcmWebAppPath | The URL up to the web application. For example, http://localhost:10039/wps/wcm |
wcmServletPath | The servlet path to the Web Content Manager
servlet. For example, /connect |
param | This is the name of the parameter that the path string is in. |
project | The name of the project to set in the context. If the corresponding project cannot be found, it is ignored and an error is logged. An empty string is used to clear any project that is previously set in the context. |
defaultPath | If the location parameter does not resolve to a valid location, then the value
of the defaultPath is used. For example, /library2/sitearea1 |
Developers can add context tags at any place in the page and it changes the context for the rest of the page execution, but the tags cannot be nested.
Rendering tags
These tags are equivalent to element and component tags.
- Rendering an element from the current site area, or content item
<wcm:contentComponent type=" " key=" " > [Error Message] </wcm:contentComponent>
Table 4. Parameters Parameter Details type This parameter determines where the element is being referenced from. Either content or sitearea. key This parameter is the name of the element that is being referenced. <wcm:libraryComponent name=" " library=" " > [Error Message] </wcm:libraryComponent >
- Rendering a component from the Component Library
Table 5. Parameters Parameter Details name This parameter is the name of the component that is being referenced. library This parameter is the name of the library where the component is stored. Example<wcm:libraryComponent name="SC Menu Events" library="Showcase" /> You do not have access to this item. </wcm:libraryComponent >
- Rendering Content based on the current context of a page
<wcm:content pageDesign=" " > [Error Message] </wcm:content >
Table 6. Parameters Parameter Details pageDesign This name of the Presentation Template used to determine context. This parameter is optional.
Error handling
The following tag can be added to error messages to enable error handling:
<%=error%>
Plug-in tag
Rendering plug-ins can be referenced within JSP code by using a plug-in tag:
<wcm:plugin name=" " param1="value" param2="value2" >
// Your text.
</wcm:plugin>
For
more information, see Creating a plug-in tag.