Saltar al contenido

Rendering WCM Library components in non rendering portlets


// Tomar como referencia que un contenido se obtiene
// ANONIMOS: http://localhost:10039/wps/wcm/connect/<contenido>
// AUTENTIFICADOS: http://localhost:10039/wps/wcm/myconnect/<contenido>

// Get the workspace
Workspace workspace = Repository.getWorkspace("admin user id", "admin user id Password");

// set current working library
workspace.setCurrentDocumentLibrary(workspace.getDocumentLibrary("name of the library where you have your components"));

// retrieve library component 
DocumentIdIterator docIds=workspace.findByName(DocumentTypes.LibraryComponent,"component name");

if (docIds.hasNext()){

	DocumentId did = (DocumentId)docIds.next();
	LibraryComponent libComp = (LibraryComponent)workspace.getById(did);

	// Create the rendering context
	RenderingContext context =  workspace.createRenderingContext(portletRequest, portletResponse, new HashMap(), "http://localhost:10039/wps/wcm", "connect");

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

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

Fuente: http://vpeddireddi.blogspot.cl/2013/12/rendering-wcm-library-components-in-non.html

Si te ha interesado este artículo y deseas un apoyo o asesoría en algún requerimiento, envíame un mensaje a: (info@juliopari.com) o sino a través de Linkedin: https://www.linkedin.com/in/juliopari/