Hi,
This code is very simple but I really don't know why it doesn't work. Could you please help me? Thanks a lot.
Best regards,
eng12042
Purpose: MyJSPDynPageDynPage instance sets value "eng12042" into MyBean instance. MyJSPDynPageDynPage instance passes this bean to JspDyn.jsp.
JspDyn.jsp prints "eng12042" into browser screen.
Problem: Nothing was printed in browser screen. That means MyBean instance in JspDyn.jsp contains no data.
Source code:
-
MyJSPDynPage.java (contains MyJSPDynPageDynPage class) -
import com.gridnode.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 MyJSPDynPage extends PageProcessorComponent {
public DynPage getPage(){
return new MyJSPDynPageDynPage();
}
public static class MyJSPDynPageDynPage extends JSPDynPage{
public void doInitialization(){
}
public void doProcessAfterInput() throws PageException {
}
public void doProcessBeforeOutput() throws PageException {
MyBean myBean = new MyBean();
((IPortalComponentRequest)getRequest()).getServletRequest().setAttribute("myBean", myBean);
// fill your bean with data here...
myBean.setName("eng12042");
this.setJspName("JspDyn.jsp");
}
}
}
-
-
JspDyn.jsp -
<%@ taglib uri="prt:taglib:tlhtmlb" prefix="hbj" %>
<jsp:useBean
id="myBean"
scope="request"
class="com.gridnode.MyBean"
/>
<hbj:content
id="myContext">
<hbj:page
title="PageTitle">
<hbj:form
id="myFormId">
<hbj:textView
id="success_message"
design="HEADER1">
<%
success_message.setText(myBean.getName());
%>
</hbj:textView>
</hbj:form>
</hbj:page>
</hbj:content>
-
-
MyBean.java -
package com.gridnode;
import java.io.Serializable;
public class MyBean implements Serializable {
private String name;
/**
@return
*/
public String getName() {
return name;
}
/**
@param string
*/
public void setName(String string) {
name = string;
}
}