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

Accepted Solutions (1)

Accepted Solutions (1)

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

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Sorry,I missed seeing your second query.

Basically a listbox or a table is a complex component containing many elements, unlike a button or an input field.

You might understand the mvc model.Now the view part is what you see on the page.The model part is your business logic/comes from the bean.You can basically create the by writing the business logic in a bean.This bean will populate the data in the table or listbox.But inorder to do that you will have to instantiate the model for the component.Then you will write methods that can be used to populate data or do specific actions or delegate events to methods/event handlers in the controllers.

The following link should give you the idea.

http://help.sap.com/saphelp_nw04s/helpdata/en/26/f79241e9129f09e10000000a155106/frameset.htm

And this document will give you an example of using model,and clarify your many doubts on beans for htmlb.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/cefed690-0201-0010-8480-9c5...

Regards,

Harish

(Please award points for helpful answers)

Message was edited by: HARISH SUBRAMANIAN

Message was edited by: HARISH SUBRAMANIAN

Message was edited by: HARISH SUBRAMANIAN

Former Member
0 Kudos

Hi,

You error is very straight forward , you have not set the bean properly,when the scope of your bean is "application".

This is how you do it(In your controller)-

<b>((IPortalComponentRequest)getRequest()).getComponentContext().putValue("testBean4", testBean4);</b>

Regards,

Harish

(Please award points for helpful answers)

Message was edited by: HARISH SUBRAMANIAN

Former Member
0 Kudos

Hi,

Thanks for prompt reply!

I understand the bean scoping methodology now....

Second question needs to be answered...

I tried in using model after adding list box and then running but it throws me an exception:

<b>Cannot access bean property testBean4.Name in page context</b>

Regards,

Dev