cancel
Showing results for 
Search instead for 
Did you mean: 

Adding and removing pages to folder programmatically

Former Member
0 Kudos

HI,

can you provide me with code sample or links to any examples which deal with Adding and removing pages to folder programmatically.

Any documents on how to add a page to a workset programmatically will also be helpful.

Message was edited by: Kirupanand Venkatapathi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi venkatapathi,

Check out this weblog posted by prakash singh

it contains a java code.

hope this helps

regards

ravi

Answers (2)

Answers (2)

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

Hi ,

Sorry for the bad link (I left off the htm at the end):

http://help.sap.com/saphelp_nw04/helpdata/en/fd/ea5c42da4de92ce10000000a1550b0/frameset.htm

-


Quick code sample (without try/catch):

import java.util.Hashtable;
import javax.naming.Context;
import com.sapportals.portal.pcd.gl.IPcdContext;
import com.sapportals.portal.prt.jndisupport.InitialContext;
import com.sap.portal.pcm.page.IPage;
import com.sap.portal.pcm.iview.IiViews;
import com.sap.portal.pcm.INewObjectDescriptor;
import com.sapportals.portal.prt.runtime.PortalRuntime;

//********* Set up environment for PCD/JNDI call
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);
env.put(Context.SECURITY_PRINCIPAL, request.getUser());

//********* Create initial context
InitialContext iCtx = null;
iCtx = new InitialContext(env);

//********* Lookup page (or folder)
IPage myPage =(IPage)iCtx.lookup("pcd:portal_content/DanielContent/myPage");

//********* Create descriptor for new iView
IiViews iViewSrv = (IiViews)PortalRuntime.getRuntimeResources().getService(IiViews.KEY);
INewObjectDescriptor IVtoAdd = (INewObjectDescriptor)iViewSrv.instantiateDescriptor(CreateMethod.DELTA_LINK,"pcd:portal_content/DanielContent/myParent",request.getUser());

//********* Add iView to page
myPage.addiView(IVtoAdd,"testParent");

If you want to add something to a folder, you would look up the folder and cast the return value into a Context object, and then call the bind method to add the object to the folder.

Hope this helps.

Daniel

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

Hi,

Adding and removing pages (and other semantic objects) is described in the Portal Developer Guide in the section called Managing iViews and Other PCD Objects at http://help.sap.com/saphelp_nw04/helpdata/en/fd/ea5c42da4de92ce10000000a1550b0/frameset.

The above includes simple yet detailed information on adding pages to folders (PCD folders, not role folders).

As for worksets, these semantic objects are technically not public and not described in the guide.

Hope this helps.

Daniel