This section describes how to add an iView (or page) to a page.
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);
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"); ...
Create a descriptor ( NewObjectDescriptor object) for the iView or page that you want to add to your page.
IiViews iViewSrv = (IiViews) PortalRuntime.getRuntimeResources().getService(IiViews.KEY); NewObjectDescriptor iViewDescriptor = (NewObjectDescriptor)iViewSrv.instantiateDescriptor (CreateMethod.DELTA_LINK, "pcd:portal_content/testxml", request.getUser());
Add the iView descriptor to the page.
myPage.addiView(iViewDescriptor,"testxml");
The iView is automatically displayed at the bottom of the left-most column of the layout that is currently being used for the page.
If you want to place the iView into a particular column of a particular layout, you can specify a layout container into which to add the iView. The following adds the iView into the com.sap.portal.reserved.layout.Cont2 container (second column) of the current layout:
... myPage.addiView(IVtoAdd,"testxml", "com.sap.portal.reserved.layout.Cont2"); } catch(NamingException e) { }
com.sap.portal.reserved.layout.Cont2 is the container ID of the second column as defined in a standard layout.
You can also specify, as integers, the vertical position of the iView within the layout container:
... myPage.addiView(iView1,"testxml1", "com.sap.portal.reserved.layout.Cont2",1); myPage.addiView(iView2,"testxml2", "com.sap.portal.reserved.layout.Cont2",2); ...
If an iView with the same atomic name exists in the page, an error is thrown.