cancel
Showing results for 
Search instead for 
Did you mean: 

Bean related

Former Member
0 Kudos

Hi,

I have 2 queries wrt to Bean usage in JSPDynPage.

1. I am trying a very simple example which goes as follows:

Dynpage:

public void doProcessBeforeOutput() throws PageException {
      testbeanclass4 testBean4 = new testbeanclass4();
      ((IPortalComponentRequest)getRequest()).getServletRequest().setAttribute("testBean4", testBean4);      
      testBean4.setName("abcd");
      
      this.setJspName("jsp4.jsp");
    }

JSP:

<%@ taglib uri= "tagLib" prefix="hbj" %>

<hbj:content id="myContext" >
  <hbj:page title="PageTitle">
   <hbj:form id="myFormId" >
<jsp:useBean id="testBean4" scope="application" class="com.sap.jspdynpage.jsp4.testbeanclass4" />   
    <hbj:textView
	id="temp"
	>
	<%
	temp.setText(testBean4.getName());
	%>
    </hbj:textView>

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

Bean:

package com.sap.jspdynpage.jsp4;

import java.io.Serializable;

public class testbeanclass4 implements Serializable {
	String name;
	public String getName(){
		return name;
	}
	
	public void setName(String name){
		this.name = name;
	}
}

But i am unable to get what i want... i am getting blank field!!

Any pointers to where am i going wrong..

PortalApp.xml has been correctly framed!!

2. What is the use of bean model in list boxes or tables? Does it act as an arrray of objects which can be populated into the table/listbox?

I have read the help.sap.com doc on Bean Model, still some kind of clarity is missing.

Points will be awarded!!

Regards,

Dev

View Entire Topic
Former Member
0 Kudos

hi,

1.Also when you are creating a jspdynpage by the template given when you are selecting the scope as application in that , there will be automatically codes generated in the dynpage as

IPortalComponentProfile profile = ((IPortalComponentRequest)getRequest()).getComponentContext().getProfile();
		IPortalComponentResponse resp=(IPortalComponentResponse)getResponse();
			  Object o = profile.getValue("myBean");
			  if(o==null || !(o instanceof authBean)){
				myBean = new authBean();
				profile.putValue("myBean",myBean);
			  } else {
				  myBean = (authBean) o;
			  }

There is least chance of commiting a mistake as you would have did.

2.Regarding use of models

Inorder to arrange data in an organised manner.

To simplify the creation of presentation layer.

For actual data processing , querying database, implementing business rules

As in models value and the associated key is stored as one-one relation.

regards,

Ganesh