How can I render a Personalization (PZN) component using the IBM® Web Content Management (WCM) API?
Answer
The WCM API provides features to render content items as well as library components such as the Web Content Management Personalization component.
Summary of how to render personalization component in WCM
First get the user workspace
Next set the web content library.
Get the document iterator for wcm personalization component by name.
Set the rendering context where the wcm personalization component will be rendered.
Get the wcm personalization component document id
Render the wcm personalization component.
***Note:** The example code (below) renders the WCM Personalization component from a JSP (Java server page).
Example code
//finds component that matches by name
DocumentIdIterator componentIdIterator = workspace.findComponentByName("PZNCMPT");
DocumentId docId;
LibraryComponent component;
String componentName = "";
String libraryPath = "/MyLibrary";
String sitePath = "/site/sitearea";
// Create the rendering context
RenderingContext context = workspace.createRenderingContext(pageContext.getRequest(),pageContext.getResponse(), new java.util.HashMap(), "http://localhost:10038/wps/wcm", "/connect");
// Set the path (Context) to the for the site area where the component will be rendered
context.setRenderedContent(libraryPath + sitePath);
//standard out log message to browser
out.println("Log: Testing WCM API: Context Path = " + context.getPath() + "
");
//loops through the component id's found in the iterator
while(componentIdIterator.hasNext())
{
docId = (DocumentId)componentIdIterator.next();
component = (LibraryComponent) workspace.getById(docId);
componentName= (String)component.getName();
//standard out log message to browser
out.println("Log: Testing WCM API: Component name = " + componentName + "
");
// Get the rendered string
if (component instanceof LibraryComponent)
{
//standard out log message to browser
out.println("Log: Testing WCM API: " + componentName
+ " is an instance of LibraryComponent
");
String renderedContent = workspace.render(context, component);
//standard out log message to browser
out.println("Log: Testing WCM API:: Passed workspace.render(context, component)
");
//Render the PZN Component
out.println("
Render PZN Component: Test Result follows:
" + renderedContent + "
");
}// end if statement
//standard out log message to browser
out.println("The End
");
}//end while
Monday, May 31, 2010
Changing the language used in the log file
Changing the language used in the log file
By default, information in the log file is written in the language that was used for the WebSphere Portal installation. However, because WebSphere Portal supports a number of languages, you can choose to have the log file information written in a language other than that used during installation.
To change the language used for the log file, edit the file log.properties. This file is located in the following WebSphere Portal directory:
* Windows: portal_server_root\shared\app\config
* UNIX: portal_server_root/shared/app/config
* i5/OS: portal_server_root/shared/app/config
Add the following line:
locale=xx
where xx is the two-letter abbreviation for the locale. For example, to have log information generated in English, you would add the following line:
locale=en
For more language codes, check this out:
http://publib.boulder.ibm.com/infocenter/wpdoc/v6r0/index.jsp?topic=/com.ibm.wp.ent.doc/wps/adsyslog.html
By default, information in the log file is written in the language that was used for the WebSphere Portal installation. However, because WebSphere Portal supports a number of languages, you can choose to have the log file information written in a language other than that used during installation.
To change the language used for the log file, edit the file log.properties. This file is located in the following WebSphere Portal directory:
* Windows: portal_server_root\shared\app\config
* UNIX: portal_server_root/shared/app/config
* i5/OS: portal_server_root/shared/app/config
Add the following line:
locale=xx
where xx is the two-letter abbreviation for the locale. For example, to have log information generated in English, you would add the following line:
locale=en
For more language codes, check this out:
http://publib.boulder.ibm.com/infocenter/wpdoc/v6r0/index.jsp?topic=/com.ibm.wp.ent.doc/wps/adsyslog.html
Subscribe to:
Posts (Atom)