Display Member Names from WCM on jsp file

Following is a very simple example of using wcp api. Especially for beginners


Step 1: Create Porlet project. e.g. Using portlet feature of  RAD 8.0

Step 2: Create Portlet and and a jsp file which will use the wcm api to fetch all the member names.

Step3: jsp file will contain wcm related code lines like follows which is self explanatory: i.e. use jndi to have lookup for the service ( its a common way of getting any service may be PUMA, etc ) and use it.

NOTE: in order to avoid the compilation error for wcm api, the jar (ilwwcm-api.jar ) has to be in classpath of project.

new InitialContext();
WebContentService webContentService = (WebContentService) ctx.lookup("mywcm.jsp");
Workspace workspace = webContentService.getRepository().getWorkspace("portal:service/wcm/WebContentService");"XXX","YYY");
String names[] = workspace.getMemberNames();for(int i=0;i<names.length;i++){ 
out.println(names[i]);
}

Step 4:  doView() method will have code as follows which will redirect page to respective jsp.

PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
rd.include(request,response);


Step 5: Export war file from your IDE and import on portal page. Select the the portlet for the page on manage pages option of portal.

Step 6 : click the page created  on portal and see the output.

InitialContext ctx =

Comments

Popular posts from this blog

Qlik Sense Important Links

Cloud Architecture Notes

AWS Rout53 NS records do not match with whois dns records OR Your site NOT working with registered domain name? Check this...