cancel
Showing results for 
Search instead for 
Did you mean: 

Hide iView when no contents available.

Former Member
0 Kudos

Hi All,

I have an iView which has certain contents from the KM. The iView is a JSP Dynpage portal application which reads the KM and shows some links.(for eg. docs, ecternal links, etc.)

The requirement is such that if no content is available in the iView, the iView along with its tray should be hidden. This should happen at runtime only.

Is there any possible way of achieving this.

Regards,

Melwyn.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Melwyn,

Plz refer to this [post|;.

Thanks,

Mahesh

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi SDNers,

I managed to solve the above error and my remove functionality is working fine.

However i am also trying to add the iView to the page dynamically if content is available.

My question is : Is it possible to write the addiView() functionality if content exists and the removeiView() functionality if content does not exist in the same JSP Dynpage ?

I tried creating 2 JSPDynpage applications, 'Add View' for the addiView() functionality and the other 'Hide View' for the removeiView() functionality. I added the 'Add View' iview to Page A and the 'Hide View' app to Page B.

In the 'Hide View' app i am checking if content exists or not.

ie. if the 'Hide View' property "TextValue" contains the value "X' or not. If "X" 'Hide View' app should be hidden else shown.

Upon excecution when i supply the value "X" to TextValue the iView 'Hide View' is hidden when i launch Page B. Now when i change the value to any string other than "X" and select the Page A whose task is to add the iView it throws a OperationFailedException saying that the 'Target object already exists'.

When i navigate to Page B i am unable to see the 'Hide View' app.


/*This is the AddView java file*/
try {
	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);
			
	InitialContext iCtx = null;
	iCtx = new InitialContext(env);	
			
	IPage myPage = (IPage)iCtx.lookup("portal_content/com.test.portal.Demo_test/com.test.articles/com.test.PageB");
			
	IiViews iViewSrv = (IiViews)PortalRuntime.getRuntimeResources().getService(IiViews.KEY);
	INewObjectDescriptor iViewDescriptor = (INewObjectDescriptor)iViewSrv.instantiateDescriptor(CreateMethod.NEW,"portal_content/com.test.portal.Demo_test/com.test.articles/com.test.PageB/com.test.HideView",request.getUser());
			
	myPage.addiView(iViewDescriptor,"com.test.HideView");
	myPage.save();
	IPcdUtils pcdUtils = PcdAccess.getPcdUtils();
	pcdUtils.publishChanges();
			
} catch (NamingException e) {
	response.write("Naming error:" + e.getLocalizedMessage());
} catch (OperationFailedException e) {
	response.write("operation failed error:" + e.getLocalizedMessage());
}

And the code for HideView is :



String text = profile.getProperty("TextValue");
if(text.equals("X"))
  {
       try {
	java.util.Hashtable env = new java.util.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);

	InitialContext iCtx = new InitialContext(env);
	IiView myIView = null;
						
	IiViews iViewSrv = (IiViews)PortalRuntime.getRuntimeResources().getService(IiViews.KEY);
						
	Object currentObject = iCtx.lookup("portal_content/com.test.portal.Demo_test/com.test.articles/com.test.PageB/com.test.HideView");
	if (currentObject instanceof IiView) 
	{
	myIView = (IiView) currentObject;
				
	} 
	else 
	{
				
	}
						
	IPage myPage = (IPage) iCtx.lookup("portal_content/com.test.portal.Demo_test/com.test.articles/com.test.PageB");
	myPage.removeiView("com.test.HideView");
	myPage.save();
	IPcdUtils pcdUtils = PcdAccess.getPcdUtils();
	pcdUtils.publishChanges();
       } catch (Exception e) {

	response.write(e.getMessage()+e.getClass());
	StackTraceElement[] elements = e.getStackTrace();
	for(int i=0;i<elements.length;i++)
	{
	 response.write("<p>"+elements<i>.toString()+"</p>");
	}
		
      }
	

			 
}//close if 
else
{
      response.write("Hello User" + text);	
}

Could someone please provide a solution..

Regards,

Melwyn.

Former Member
0 Kudos

Hi,

I refered to the thread https://www.sdn.sap.com/irj/scn/thread?messageID=5246980 and also to the help material at http://help.sap.com/saphelp_nwce10/helpdata/en/db/cf9d4207e1c86ae10000000a155106/frameset.htm

However when i was trying to implement the code i am not able to use this method:


    IPage myPage =(IPage)iCtx.lookup("pcd:portal_content/Desktop/finance");
    myPage.removeiView("myIView");

What i am getting instead is:


    myPage.removeRelatedItem(); //This takes an IRelatedItemEntity as a parameter.

The import for IPage class is as follows:


   import com.sap.portal.pcm.page.IPage;

I am using NWDS ver 7.0.15. When i checked through the JavaDocs on SDN the method exists for SAP NW 2004s SPS10.

I was wondering how to use the removeiView() of the page.

Any insights or any other technique to achieve this would be appreciated.

Regards,

Melwyn.