Skip to Content
author's profile photo Former Member
Former Member

cannot get a simple JSPDynPage working

Hi all,

I am trying to get a simple JSPDynPage working but it seems that the data is not exchaged between the bean and Dynpage.

I am using EP6 SP6 PDK 6.6, Developer Studio 2.0.7

I created a JSPDynPage application using the Develper Studio Wizard. Than I modified it using the example HTMLB DynpageConcept from the PDK.

Here is my code:

JSP:

<%-- OutputText.jsp --%>

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

<hbj:content id="myContext" >

<hbj:page title="An Easy Start">

<hbj:form id="myFormId"

>

<%-- Declaration of the bean. --%>

<jsp:useBean id="UserNameBean" scope="application" class="bean.DynPageNameBean" />

<hbj:textView

id="welcome_message"

design="HEADER1" >

<% welcome_message.setText("May the force be with you "

+ UserNameBean.getName()); %>

</hbj:textView>

<br><br>

<hbj:label

id="label_input"

text="Your name please"

design="LABEL"

required="TRUE"

labelFor="user_name_input"

/>

<%-- inputfield to allow userinput - the inputfield has the id "user_name_input" which is --%>

<%-- used in the JSP DynPage to access the input field and retrieve the input of the user --%>

<hbj:inputField

id="user_name_input"

type="STRING"

design="STANDARD"

width="250"

maxlength="30"

/>

<hbj:button

id="Send_Button"

text="Send"

tooltip="Sends my name"

onClick="onSendButtonClicked"

width="100"

design="EMPHASIZED" >

<% myFormId.setDefaultButton(Send_Button); %>

</hbj:button>

</hbj:form>

</hbj:page>

</hbj:content>

Java:

package com.mycompany.basicexample;

import bean.DynPageNameBean;

import com.sapportals.htmlb.*;

import com.sapportals.htmlb.enum.*;

import com.sapportals.htmlb.event.Event;

import com.sapportals.htmlb.page.DynPage;

import com.sapportals.htmlb.page.PageException;

import com.sapportals.portal.htmlb.page.JSPDynPage;

import com.sapportals.portal.htmlb.page.PageProcessorComponent;

import com.sapportals.portal.prt.component.IPortalComponentContext;

import com.sapportals.portal.prt.component.IPortalComponentProfile;

import com.sapportals.portal.prt.component.IPortalComponentRequest;

/*public class DynPageOne extends PageProcessorComponent {

public DynPage getPage(){

return new DynPageOneDynPage();

}*/

public class DynPageOne extends JSPDynPage{

private final static int INITIAL_STATE = 0;

private final static int WELCOME_STATE = 1;

private int state = INITIAL_STATE;

private String name;

private DynPageNameBean UserNameContainer;

public DynPageOne() {

this.setTitle("DynPageOne");

}

public void doInitialization(){

// create the bean and set a default text value "unknown user

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

IPortalComponentContext myContext = request.getComponentContext();

IPortalComponentProfile myProfile = myContext.getProfile();

// new bean object

UserNameContainer = new DynPageNameBean();

// set default name

UserNameContainer.setName("unknown user");

// store bean in profile for the JSP

myProfile.putValue("UserNameBean", UserNameContainer);

// Now we set the state so that we can decide what action to do next

state = INITIAL_STATE;

}

public void doProcessAfterInput() throws PageException {

// get the input field from the JSP

InputField myInputField = (InputField) getComponentByName("user_name_input");

if (myInputField != null) {

this.name = myInputField.getValueAsDataType().toString();

}

IPortalComponentRequest request

= (IPortalComponentRequest) this.getRequest();

IPortalComponentContext myContext = request.getComponentContext();

IPortalComponentProfile myProfile = myContext.getProfile();

DynPageNameBean myNameContainer

= (DynPageNameBean) myProfile.getValue("MyNameBean");

myNameContainer.setName(name);

}

public void doProcessBeforeOutput() throws PageException {

switch (state) {

case WELCOME_STATE:

this.setJspName("OutputSuccessText.jsp");

break;

default:

this.setJspName("OutputText.jsp");

break;

}

}

public void onSendButtonClicked (Event event) throws PageException { state = WELCOME_STATE;

}

// }

}

portalapp.xml:

<?xml version="1.0" encoding="utf-8"?>

<application>

<application-config>

<property name="SharingReference" value="htmlb"/>

</application-config>

<components>

<component name="DynPageOne">

<component-config>

<property name="ClassName" value="com.mycompany.basicexample.DynPageOne"/>

<property name="SecurityZone" value="com.mycompany.basicexample/no_safety"/>

<property name="ComponentType" value="jspnative"/>

<property name="JSP" value="pagelet/OutputText.jsp"/>

</component-config>

<component-profile>

<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>

</component-profile>

</component>

</components>

<services/>

</application>

Bean:

package bean;

/*

  • A very simple bean whose only purpose is to store a simple String.

  • It as a get and set method to store and recall the string.

*/

public class DynPageNameBean

{

public String name;

public String getName ()

{

return this.name;

}

public void setName (String name)

{

this.name = name;

}

}

After I first time run this example, i am supposed to get something like "May the force be with you unknown user", but instead i always get "May the force be with you null", so the data is not exchanged (the "name" var is never set in the bean"). I am not sure that it ever gets to the point:

UserNameContainer.setName("unknown user");

How can I check this???

I would be very happy if anyone can help me with this.

Thank you!!!

Sanda

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2005 at 06:56 PM

    I have this exact same problem. Has anyone solved it yet?

    Thanks.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 08, 2004 at 10:56 PM

    Hi Sanda,

    there are a lot of things irritating me. I haven't heard of so many changes in JSPDynPro development, on the other hand, I am still on EP6 SP2, so I'm not sure... Anyhow, I will just write down what you would have to change to make it run on SP2, just try it... (in the order given, step by step, maybe the changes are there, but only some):

    1.) Delete the two lines in portalapp.xml

    <property name="ComponentType" value="jspnative"/>

    <property name="JSP" value="pagelet/OutputText.jsp"/>

    2.) Uncomment

    /*public class DynPageOne extends PageProcessorComponent {

    public DynPage getPage(){

    return new DynPageOneDynPage();

    }*/

    3.) Rename resulting inner class DynPageOne into DynPageOneDynPage; don't forget to uncomment the braces in the line before last.

    Hope it helps

    Detlev

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.