on 01-13-2006 11:46 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
73 | |
8 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.