This section describes how to add a layout to a page.
Each page is assigned a default layout, which is used for rendering the page. You can assign other layouts to a page to enable users to personalize the page. Users can then select one of the other layouts assigned to the page.
...
1. Set the parameters for a JNDI lookup in the PCD.
Hashtable env =
new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);
env.put(Context.SECURITY_PRINCIPAL, request.getUser());
env.put(Constants.REQUESTED_ASPECT, PcmConstants.ASPECT_SEMANTICS);
2. Perform a lookup of the page to which you want to add an iView.
InitialContext iCtx = null;
try
{
iCtx = new InitialContext(env);
IPage myPage =(IPage)iCtx.lookup(
"pcd:portal_content/Desktop/finance");
...
3. Create a descriptor (INewObjectDescriptor object) for the layout that you want to add to your page.
ILayouts layoutSrv = (ILayouts)
PortalRuntime.getRuntimeResources().getService(ILayouts.KEY);
INewObjectDescriptor layoutToAdd =
(INewObjectDescriptor) layoutSrv.instantiateDescriptor
(CreateMethod.DELTA_LINK,
"pcd:portal_content/templates/layouts/narrowWide",
request.getUser());
4. Add the layout descriptor to the page.
...
myPage.addLayout(layoutToAdd, "newLayout");
}
catch(NamingException e)
{
}
If a layout with the same atomic name exists in the page, an error is thrown.