Skip to Content
0
Former Member
May 08, 2007 at 08:09 AM

jsp webdypro problem

33 Views

Hi,

i have a problem, and i don't know how to sove it, if someone can help me, will be very nice for me.

i have webdynpro application, which using this:

String pcd_link = "ROLES://portal_content/MyFolder/g_navigation1/portal_g_navigation";

String params = "?p1=2";

WDPortalNavigation.navigateAbsolute(pcd_link,WDPortalNavigationMode.SHOW_INPLACE,"toolbar=yes,menubar=yes,location=yes",(String)null, WDPortalNavigationHistoryMode.NO_HISTORY,"Title","",params);

then in a portal application, i want to take this url parameter, and put in a bean class field.

-


package com.teamr3;

import com.teamr3.beanclassname;
import com.sapportals.htmlb.*;
import com.sapportals.htmlb.enum.*;
import com.sapportals.htmlb.event.*;
import com.sapportals.htmlb.page.*;
import com.sapportals.portal.htmlb.page.*;
import com.sapportals.portal.prt.component.*;

public class classname_g_navigation extends PageProcessorComponent {

  public DynPage getPage(){
    return new classname_g_navigationDynPage();
  }

  public static class classname_g_navigationDynPage extends JSPDynPage{
  
    private beanclassname myBean = null;
  
    public void doInitialization(){
      IPortalComponentSession componentSession = ((IPortalComponentRequest)getRequest()).getComponentSession();
      Object o = componentSession.getValue("myBean");
      if(o==null || !(o instanceof beanclassname)){
        myBean = new beanclassname();
        componentSession.putValue("myBean",myBean);
      } else {
          myBean = (beanclassname) o;
      }
      
      // fill your bean with data here...
    }

    public void doProcessAfterInput() throws PageException {
    }

    public void doProcessBeforeOutput() throws PageException {
	  IPortalComponentRequest request = (IPortalComponentRequest)this.getRequest();
	   String PosId;
 	   PosId = request.getParameter("p2"); //p2
		   if (PosId != null)
		   {
	                        myBean.passname = PosId; 
		   }
		   else
		   {
			   myBean.passname = "POSID:44";
		   }
      this.setJspName("display.jsp");
    }
  }
}

The bean class:

package com.teamr3;
import java.io.Serializable;
public class beanclassname implements Serializable {
	public String passname;
	public String getPassname()
	{
		return this.passname;
	}

	public void setPassname(String passname)
	{
		this.passname = passname;
	}
}

and this the portalapp.xml file:

<?xml version="1.0" encoding="utf-8"?>
<application>
  <application-config>
    <property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>
  </application-config>
  <components>
    <component name="classname_g_navigation">
      <component-config>
        <property name="ClassName" value="com.teamr3.classname_g_navigation"/>
        <property name="ComponentType" value="jspnative"/>
        <property name="JSP" value="pagelet/display.jsp"/>
      </component-config>
      <component-profile>
        <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
      </component-profile>
    </component>
  </components>
  <services/>
</application>

the jsp file:

<%@ taglib uri= "tagLib" prefix="hbj" %>
<jsp:useBean id="myBean" scope="request" class="com.teamr3.beanclassname" />
<hbj:content id="myContext" >
  <hbj:page title="PageTitle">
   <hbj:form id="myFormId" >
		portal jsp dyn page
		<br/>
		<% response.write("<br>xxxx-" + myBean.getPassname() + "-zzzz<br>"); %>
 		<br/>
		<hbj:textView id="txtEname" text="<%=myBean.getPassname()%>"/>	

   </hbj:form>
  </hbj:page>
</hbj:content>

this is the url, after i click the button in webdynpro View, that lead to the portal application:

<a href="http://localhost:50000/irj/portal?NavigationTarget=ROLES%3A//portal_content/MyFolder/g_navigation1/portal_g_navigation&DynamicParameter=%3Fp1%3D2&NavigationContext=&windowId=WID1178611594893">http://localhost:50000/irj/portal?NavigationTarget=ROLES%3A//portal_content/MyFolder/g_navigation1/portal_g_navigation&DynamicParameter=%3Fp1%3D2&NavigationContext=&windowId=WID1178611594893</a>

After all this: when start this to work, it redirects me to the portal application but the url is doesn't used for setting the myBean.getPassname and no result is dispayed, and just null.

I don't know why 😔

If someone can help me?

Thank you in advance.

BR

Diana