cancel
Showing results for 
Search instead for 
Did you mean: 

JSPDynPage event not firing

Former Member
0 Kudos

Hi, <p>

I created a JSPDynPage and subsequently coded the corresponding jsp and java file(s).</p>

<b>JSP</b><p>

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

<hbj:content id = "myContext"><br>

<hbj:page title="Check LockOut Count"><br>

<hbj:form id="myForm"> <br>

<hbj:textView id="welcome_message" design="header1" text="Please enter the following information:"/><br>

<hbj:gridLayout><br>

<hbj:gridLayoutCell rowIndex="1" columnIndex="1"><br>

<hbj:label id="lblLoginID" required="true" text="Login ID:" design="Label" labelFor="txtLoginID"/><br>

</hbj:gridLayoutCell><br>

<hbj:gridLayoutCell rowIndex="1" columnIndex="2"><br>

<hbj:inputField id="txtLoginID" type="string" maxlength="100"/><br>

</hbj:gridLayoutCell><br>

</hbj:gridLayout><br>

<hbj:button id="btnSubmit" text="Check" onClick="btnSubmitClicked" width="100" design="emphasized" /><br>

</hbj:form><br>

</hbj:page><br>

</hbj:content><br>

</p>

<br>

<b>Java File</b>

<p>package com.WebService.ActiveDirectory;<br><br>

import com.WebService.CheckPasswordExpiryResponse;<br>

import com.sapportals.htmlb.InputField;<br>

import com.sapportals.htmlb.event.Event;<br>

import com.sapportals.htmlb.page.DynPage;<br>

import com.sapportals.htmlb.page.PageException;<br>

import com.sapportals.portal.htmlb.page.JSPDynPage;<br>

import com.sapportals.portal.htmlb.page.PageProcessorComponent;<br>

import com.sapportals.portal.prt.component.IPortalComponentResponse;<br>

import com.sapportals.portal.prt.runtime.PortalRuntime;<br><br>

public class CheckLockOutCount extends PageProcessorComponent {<br><br>

public DynPage getPage(){<br>

return new CheckLockOutCountDynPage();<br>

}<br><br>

public static class CheckLockOutCountDynPage extends JSPDynPage{<br>

private String loginID;<br>

private String results;<br>

<br>

public CheckLockOutCountDynPage() {<br>

this.setTitle("Check LockOut Count");<br>

}<br>

<br>

public void doInitialization(){<br>

} <br><br>

public void doProcessAfterInput() throws PageException {<br>

InputField txtLoginID = (InputField)getComponentByName("txtLoginID");<br>

this.loginID = txtLoginID.getValue().toString(); <br>

}<br><br>

public void doProcessBeforeOutput() throws PageException { <br>

}<br><br>

public void onbtnSubmitClicked(Event event) throws PageException {<br>

IPortalComponentResponse response = (IPortalComponentResponse)this.getResponse();<br>

response.write("<script language='JavaScript'>");<br>

response.write("alert('Event fired');");<br>

response.write("</script>");<br>

} <br>

}<br>

}<br><br>

</p><br>

<b>Expected results</b>

<p>Once the user enters the login ID and click the "Check" button, the user should receive a Java Alert message, which says "Event fired". However, when the button is clicked, nothing happens. The page refreshes and the input field is reset.<br>

Can anyone point out what went wrong?</p>

<br>

Thank You.

Message was edited by:

Voon Siong Lum

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I made the following change to your code and its working perfectly:

public void doProcessBeforeOutput() throws PageException

{

this.setJspName("YourJSPName.jsp");

}

You can have a look at the code:

<b>JSP:</b>


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

<hbj:content id="myContext" >
  <hbj:page title="PageTitle">
   <hbj:form id="myFormId" >
        <hbj:textView 
             id="welcome_message" design="header1" text="Please enter the following information:"/> 
        <hbj:gridLayout> 
             <hbj:gridLayoutCell rowIndex="1" columnIndex="1"> 
                  <hbj:label id="lblLoginID" required="true" text="Login ID:" design="Label" labelFor="txtLoginID"/> 
             </hbj:gridLayoutCell> 
             <hbj:gridLayoutCell rowIndex="1" columnIndex="2"> 
                  <hbj:inputField id="txtLoginID" type="string" maxlength="100"/> </hbj:gridLayoutCell> 
             </hbj:gridLayout> 
       <hbj:button id="btnSubmit" text="Check" onClick="btnSubmitClicked" width="100" design="emphasized" />
   </hbj:form>
  </hbj:page>
</hbj:content>

<b>JAVA:</b>


package satyam.sap.pooja;
import com.sapportals.htmlb.InputField;
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.IPortalComponentResponse;

public class MyJSPDynPage extends PageProcessorComponent {

  public DynPage getPage(){
    return new MyJSPDynPageDynPage();
  }

  public static class MyJSPDynPageDynPage extends JSPDynPage{
  
    private String loginID; 
	private String results; 
    
    public void doInitialization(){
    }

    public void doProcessAfterInput() throws PageException {
    	
		InputField txtLoginID = (InputField)getComponentByName("txtLoginID");         
		this.loginID = txtLoginID.getValue().toString(); 
    }

    public void doProcessBeforeOutput() throws PageException {
		this.setJspName("Display.jsp");
    }
    
	public void onbtnSubmitClicked(Event event) throws PageException 

		 { 

			IPortalComponentResponse response = (IPortalComponentResponse)this.getResponse(); 

			response.write("<script language='JavaScript'>"); 

			response.write("alert('Event fired');"); 

			response.write("</script>"); 

		  } 
  }
}

Regards,

Pooja.

Former Member
0 Kudos

Thanks Pooja. One thing though, I had to change onClick="btnSubmitClicked" to onClick="onbtnSubmitClicked".

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

In the event handler you are only putting some javascript code but not triggering any javascript events.

Since you want only a javascript event to occur you can call

onClientClick for the button in the jsp and write a function say check:


<hbj:button id="btnSubmit" text="Check" 
onClientClick="javascript: check()"
onClick="btnSubmitClicked" width="100" design="emphasized" />

And in the jsp mention the javascript code such as :


<script language='JavaScript'>
function check()
{
alert('Event fired');
}
</script>

This should get your required output.

Regards,

Sujana