Skip to Content
0
Former Member
Jul 18, 2008 at 07:00 AM

doubts in Data Storing / Retrieving on JSPDynPage and Bean

15 Views

Hi all,

I wanted to try this example on [saphelp|http://help.sap.com/saphelp_nw04/helpdata/en/ce/e0a341354ca309e10000000a155106/frameset.htm]

There is a bean a JSPDynPage and a jsp. In the bean I am setting the String "testValue" to "no_novValue". In the doInitialization() method I set the value "testValue" to "newValue". In the jsp I want to display the value, but I am still getting the old value (no_Value).

Can anyone guide me what I am doing / understanding wrong ?

Here is my code:

Bean:

package com.asstec;

import java.io.Serializable;

public class RolesBean implements Serializable {

	private String testValue = "no_Value";

	/**
	 * @return
	 */
	public String getTestValue() {
		return testValue;
	}

	/**
	 * @param string
	 */
	public void setTestValue(String string) {
		testValue = string;
	}

}

JSPDynPage

package com.asstec;

import com.asstec.RolesBean;
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 RolesApp extends PageProcessorComponent {

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

  public static class RolesAppDynPage extends JSPDynPage{
  
    private RolesBean myBean = null;
  
    public void doInitialization(){
      IPortalComponentProfile profile = ((IPortalComponentRequest)getRequest()).getComponentContext().getProfile();
      Object o = profile.getValue("myBean");
      if(o==null || !(o instanceof RolesBean)){
        myBean = new RolesBean();
		
        profile.putValue("myBean",myBean);
      } else {
          myBean = (RolesBean) o;
      }
      // fill your bean with data here...
	  myBean.setTestValue("newValue");
    }

    public void doProcessAfterInput() throws PageException {
    }

    public void doProcessBeforeOutput() throws PageException {
      this.setJspName("RolesAppJSP.jsp");
    }
  }
}

and the jsp page


<jsp:useBean id="myBean" scope="application" class="com.asstec.RolesBean" />
<hbj:content id="myContext" >
  <hbj:page title="PageTitle">
   <hbj:form id="myFormId" >
	<%= myBean.getTestValue() %>
   </hbj:form>
  </hbj:page>
</hbj:content>