Link to home
Start Free TrialLog in
Avatar of pwill40
pwill40

asked on

Embedding Javascript in a jsp page

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
ASKER CERTIFIED SOLUTION
Avatar of Nushi
Nushi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nushi
Nushi

if its still doesnt work use:

<script language='javascript'>
...


Nushi.
The whole thing looks strange. Have you defined a javascript class or object called EPCM?
Avatar of Michel Plungjan
var data = "<%= EPCM.loadClientData( "urn:com.sap.pct.hcm.HCMCKey:CurrentObject", "P ") %>";
would possibly help if there are no crlf in the clientData

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pwill40

ASKER

Thank you one and all for your comments.  All were appreciated

Cheers,
Paul