Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

JSPDyn page using a bean

Trying to create a pretty simple JSPDyn page with a single bean. I am using NWDS to generate the code. I am trying to set some initial data in bean to be used on the page later, but it always comes back as NULL. It's like the creation the generation of the page creates a new instance of bean and loses the reference I create in the controller.

Here is the code for the dynpage controller:


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

public class myTest extends PageProcessorComponent {

  public DynPage getPage(){
    return new myTestDynPage();

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

    public void doProcessAfterInput() throws PageException {

    public void doProcessBeforeOutput() throws PageException {

Notice I am setting the data up after the comment "//fill your bean data here". SAP code generator inserted this comment.

and here is the bean code



public class bean implements Serializable {
	private String output;
	public String getOutput( ){
		return output;
	public void setOutput( String value ){
		output = value;

and finally the jsp page

<jsp:useBean id="myBean" scope="application" class="" />
<hbj:content id="myContext" >
  <hbj:page title="PageTitle">
   <hbj:form id="myFormId" >
     The value of Output is <%= myBean.getOutput( ) %>

the output is:

The value of Output is null

Anyone have any idea what I am doing wrong here.

Thanks in advance.



Hi Clark,

Open the portalapp.xml and delete these two lines

<property name="ComponentType" value="jspnative"/>

<property name="JSP" value="pagelet/myTest.jsp"/>

Rebuild and deploy and it should work.



0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question