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.Resource Bundle" %>
<%@ page import="com.sap.pct.hcm.or gmanagemen teventing. CKey" %>
<jsp:useBean id="valueBean" scope="application" class="bean.bukrsHelper" />
<jsp:useBean id="cKey" scope="request" class="com.sap.pct.hcm.org management eventing.C Key" />
<jsp:setProperty name="valueBean" property="dispPosNum" />
<%
String targetURL = componentRequest.createCom ponentURL( componentR equest.get Node(), null);
String jsFunctionName = "handle_addToShoppingCart_ Event_" + componentRequest.getCompon entContext ().getValu e("COMPONE NT_ID");
%>
start
<script>
alert("In First Script.")
document.write "before subscribe event";
EPCM.subscribeEvent( 'urn:com.sap.pct.hcm.orgma nagement:C urrentObje ct', '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.HCMCK ey:Current Object", "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
Code:
<%@ page import="java.util.Resource
<%@ page import="com.sap.pct.hcm.or
<jsp:useBean id="valueBean" scope="application" class="bean.bukrsHelper" />
<jsp:useBean id="cKey" scope="request" class="com.sap.pct.hcm.org
<jsp:setProperty name="valueBean" property="dispPosNum" />
<%
String targetURL = componentRequest.createCom
String jsFunctionName = "handle_addToShoppingCart_
%>
start
<script>
alert("In First Script.")
document.write "before subscribe event";
EPCM.subscribeEvent( 'urn:com.sap.pct.hcm.orgma
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.HCMCK
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The whole thing looks strange. Have you defined a javascript class or object called EPCM?
var data = "<%= EPCM.loadClientData( "urn:com.sap.pct.hcm.HCMCK ey:Current Object", "P ") %>";
would possibly help if there are no crlf in the clientData
would possibly help if there are no crlf in the clientData
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you one and all for your comments. All were appreciated
Cheers,
Paul
Cheers,
Paul
<script language='javascript'>
...
Nushi.