We help IT Professionals succeed at work.
Get Started

Embedding Javascript in a jsp page

pwill40
pwill40 asked
on
924 Views
Last Modified: 2008-01-09
I'm trying to embed javascript in a jsp page but it seems as if the javascript I have written is being ignored:

Code:

<%@ page import="java.util.ResourceBundle" %>
<%@ page import="com.sap.pct.hcm.orgmanagementeventing.CKey" %>

<jsp:useBean id="valueBean" scope="application" class="bean.bukrsHelper" />
<jsp:useBean id="cKey" scope="request" class="com.sap.pct.hcm.orgmanagementeventing.CKey" />
<jsp:setProperty name="valueBean" property="dispPosNum" />


<%
  String targetURL = componentRequest.createComponentURL(componentRequest.getNode(), null);
  String jsFunctionName = "handle_addToShoppingCart_Event_" + componentRequest.getComponentContext().getValue("COMPONENT_ID");
%>

start

<script>

  alert("In First Script.")
  document.write "before subscribe event";

 
  EPCM.subscribeEvent( 'urn:com.sap.pct.hcm.orgmanagement:CurrentObject',  'objectChanged', <%=jsFunctionName%> );

  function <%=jsFunctionName%> ( evt ) {
    alert("Please enter predictions for all the games.")
    document.write ("In function");    
    document.write evt;  
    location.href = '<%=targetURL%>';
  }

</script>
<SCRIPT language ="JavaScript">
  var data = EPCM.loadClientData( "urn:com.sap.pct.hcm.HCMCKey:CurrentObject", "P ");
  alert("After Load Client Data")  
  if ( data != null) {
    document.write data;
  }
</SCRIPT>

end

End of Code:

Within this extract none of the write commands or alert command seem to do anything.  All that gets written to the screen is "start" and "end"

Many THanks,
Paul
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 2 Answers and 6 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE