Skip to Content
0
Former Member
Jun 19, 2006 at 12:49 PM

JspDynPage - HTMLB - Events not called

24 Views

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>