on 02-27-2006 8:00 AM
I am trying a very simple example.But i am unable to get what i want... i am getting blank field(null)
Source code goes as follows:
Dynpage:
package com.abc.basicexample;
import com.abc.basicexample.myBean;
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 b extends PageProcessorComponent {
public DynPage getPage(){
return new bDynPage();
}
public static class bDynPage extends JSPDynPage{
public void doInitialization(){
}
public void doProcessAfterInput() throws PageException {
}
public void doProcessBeforeOutput() throws PageException {
((IPortalComponentRequest)getRequest()).getServletRequest().setAttribute("myBean", myBean);
myBean myBean = new myBean();
myBean.setName("bb");
this.setJspName("jsp2.jsp");
}
}
}
JSP:
<jsp:useBean id="myBean" scope="request" class="com.abc.basicexample.myBean" />
<hbj:content id="myContext" >
<hbj:page title="PageTitle">
<hbj:form id="myFormId" >
before:<%
out.println(myBean.getName());
/*myBean.setName("this my first Bean");
out.println("<br>");
out.println("after:");
out.println(myBean.getName());
*/
%>
</hbj:form>
</hbj:page>
</hbj:content>
Bean:
package com.abc.basicexample;
import java.io.Serializable;
public class myBean implements Serializable {
public String name;
public void setName(String name)
{
this.name=name;
}
public String getName()
{
return name;
}
}
Any pointers to where am i going wrong..
Thanks & Regards,
Hi
Please try the following steps:
First delete the lines created by wizard from portapp.xml
file:
<property name="ComponentType"value="jspnative"/>
<property name="JSP" value="pagelat/ (jsp name).jsp"/>
then change the lines:
<component-profile>
<property name="tagLib"value="/SERVICE/htmlb/taglib/htmlb.tld"/>
</component-profile>
In JSP add as first line:
<%@ taglib url="tagLib"prefix="hbj"%>
hope this helps you to solve your problem.
If it helps you please let me know.
PS:Dont forget to reward points if you find its useful.
Regards
Victoria
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You have made a small mistake, I believe this to be the reason.
public void doProcessBeforeOutput() throws PageException {
((IPortalComponentRequest)getRequest()).getServletRequest().setAttribute("myBean", myBean);
myBean myBean = new myBean();
myBean.setName("bb");
this.setJspName("jsp2.jsp");
}
In this code myBean object is instantiated after setting it in the servlet request.
Please do it as below.This should solve your problem.
<b>myBean myBean = new myBean();
((IPortalComponentRequest)getRequest()).getServletRequest().setAttribute("myBean", myBean);
myBean.setName("bb");
this.setJspName("jsp2.jsp");
</b>
By the way , why are you using the same name for both the class and the object?
Regards,
Harish
(Please award points for helpful answers)
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,
Add d following line at d start of ur <b>jsp</b>.
<i><%@ taglib uri="tagLib" prefix = "hbj" %</i>>
Include the following piece of code in <b>portalapp.xml</b>.
<i><component-profile>
<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
</component-profile></i>
Check if u've removed the following lines from ur <b>portalapp.xml</b>:
<i><property name="ComponentType" value="jspnative"/>
<property name="JSP" value="pagelet/myjsp.jsp"/></i>
Hope this helps.
Regards,
M.Subathra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.