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

JspDynPage - HTMLB - Events not called

Hello,

writing my first JSP within the Portal, i have some Problems ,as the following methods are not called:

- doProcessAfterInput

- doProcessAfterInput

- onUpdate (Event Handler declared on button)

The JSP page is displayed, but the bean was created in the testpage.jsp page itself and not in my JSPDynPage class.

I'm also not able to debug my JspDynPage, only the Bean methods are traceable.

At the moment i do not see what's wrong in this small example - so I appreciate very much any hint and tip to solve this problem.

Thanks in advance for any help

Reto

<u>JSPDynPage:</u>

public class TestPortletDynPage extends JSPDynPage {

	    /*   Constructor  */
			public TestPortletDynPage() {
					this.setTitle("TestPortletDynPage");
			}
			
		public void doInitialization() {
			IPortalComponentSession componentSession = ((IPortalComponentRequest) getRequest()).getComponentSession();
			Object o = componentSession.getValue("myBean");
			TestBean myBean;
			if (o == null || !(o instanceof TestBean)) {
				myBean = new TestBean();
				componentSession.putValue("myBean", myBean);
			} else {
				myBean = (TestBean) o;
			}
			myBean.setName("New");
		}

		public void doProcessAfterInput() throws PageException {
			//get the input field from the JSP
			String name = "?";
			InputField myInputField = (InputField) getComponentByName("name_in");
			if (myInputField != null) {
				name = myInputField.getValue().toString();
			}
			IPortalComponentSession componentSession = ((IPortalComponentRequest) getRequest()).getComponentSession();
			Object o = componentSession.getValue("myBean");
			TestBean myBean;
			if (o == null || !(o instanceof TestBean)) {
				myBean = new TestBean();
				myBean.setName("New After Input");
				componentSession.putValue("myBean", myBean);
			} else {
				myBean = (TestBean) o;
			}
			myBean.setName(name);
		}

		public void doProcessBeforeOutput() throws PageException {

			this.setJspName("TestPage.jsp");
		}

		/**
			* this method handles the event of the button. The event is fired 
			* either when the user clicks on the button or presses the 
			* Return/Enter key when he is in the inputField (since we defined 
			* the button as default button). In this method we set the state to 
			* WELCOME_STATE so that on the following doProcessBeforeOutput 
			* (which is called immediately after this method) a success message is displayed
			*/
		public void onUpdate(Event event) throws PageException {
			System.out.println("Event->"+event.toString());
		}
	}

<u>JSP Page:</u>

<%@ taglib uri= "tagLib" prefix="hbj" %>
<hbj:content id="myContext" >
  <hbj:page title="PageTitle">
   <hbj:form id="myFormId" >
	   <jsp:useBean id="myBean" scope="session" class="TestBean" />
	   <hbj:textView id="welcome_message" design="HEADER1" ><% welcome_message.setText("TestBean "+myBean.getName()); %></hbj:textView>
	   <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="name_in"  type="STRING" design="STANDARD" width="250" maxlength="30"  value="<%= myBean.getName() %>" />
	   <br>
	   <hbj:button id="Update" encode="false" text="Update" width="125px" tooltip="Click here to update test data."
	               onClick="Update" disabled="false" design="STANDARD"/>
   </hbj:form>
  </hbj:page>
</hbj:content>

<u>PortalApp.xml</u>

<application>
  <application-config>
    <property name="SharingReference" value="com.sap.portal.htmlb"/>
  </application-config>
  <components>
    <component name="TestPortlet">
      <component-config>
        <property name="ClassName" value="TestPortlet"/>
        <property name="ComponentType" value="jspnative"/>
        <property name="JSP" value="pagelet/TestPage.jsp"/>
      </component-config>
       <component-profile>
        <property name="tagLib"  value="/SERVICE/htmlb/taglib/htmlb.tld"/>
      </component-profile>
    </component>
   </components>
  <services/>
</application>

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 Jun 20, 2006 at 08:33 AM

    Hello Reto,

    I found some issues, that might cause the problem:

    1. Do you use the default package? I did not find any packages names in your code ("package com.mycompany.portal" for example). I often had trouble when using the default package.

    2. Your doInitialization() method does not throw a PageException

    3. Try using the real method name when declaring the event handling method for your button. So I suggest replacing "Update" with "onUpdate".

    4. Try removing the following snippet from your portalapp.xml:

    <property name="ComponentType" value="jspnative"/>
            <property name="JSP" value="pagelet/TestPage.jsp"/>

    . Instead, add an entry for the safety level with priority "low". I recommend using the Developer Studio wizard for this task. Don't forget to update the package names in portalapp.xml if you change them in your *.java files.

    Otherwise, I could send you a little example iView that I developed.

    Regards, Lars

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 20, 2006 at 08:35 AM

    Hello,

    i rewrote the portlet extending from AbstractPortalComponent and checked for the events. Everything works fine - even the debugger is usable and it follows more closely the JSR 168 standards. Is there information available about the preferred way developing portlets in SAP Portal?

    Thanks for any idea

    Reto

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Reto,

      I don't think that there is a preferred method for developing iViews/portlets. If you're familar with developing Dynpros, you should go with the (JSP)DynPage approach, since it uses the same programming model. If you're familar with portlets and the JSR168 standard, I'd recommend using the AbstractPortalComponent as base class for your iViews/portlets, since it might be easier to migrate a portlet from SAP's API to JSR168 API and vice versa.

      If you don't like programming, you could use Visual Composer to develop your portal components in a model driven way.

      Kind regards, Lars

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.