When I run http://localhost:18080/commission/dwr/test/jsTestIt it works perfectly. So I know everything is set up okay.
The problem comes when I try to incorporate the scripts into my STRUTS/JSP page.
I have literally copied the code from the testing page (.../dwr/test/jsTestIt) into my jsp page
getProgram( <input class='itext' type='text' size='10' value='""' id='p00' title='Will be converted to: java.lang.String'/> );
<input class='ibutton' type='button' onclick='jsTestIt.getProgram(objectEval($("p00").value), reply0);' value='Execute' title='Calls jsTestIt.getProgram(). View source for details.'/>
var reply0 = function(data)
if (data != null && typeof data == 'object') alert(dwr.util.toDescriptiveString(data, 2));
else dwr.util.setValue('d0', dwr.util.toDescriptiveString(data, 1));
<span id='d0' class='reply'></span>
text = text.replace(/\n/g, ' ');
text = text.replace(/\r/g, ' ');
text = '[' + text + ']';
The problem is, showing to be in the line above in red. The Chrome debugging tool says:
"Uncaught TypeError Cannot read property 'replace' of undefined "
Obviously this code works on the TEST page. What is going on here?
The error message says that you are calling your function objectEval with its "text" parameter set to undefined. Put a breakpoint in the Chrome debugger to see where this is coming from.
Michael Moore wrote:
In reply to this post by mmoore
Instead of copying code from the test page without understanding anything that is going on I recommend downloading the dwr.war and taking a look at some of the examples. The test pages are automatically generated and not how you want to do things in your application. That being said this error is being thrown because the 'text' argument is undefined. My guess is you are not including the DWR util scripts and the value of the text input is not being sent to objectEval ($("p00").value).
On 03/31/2015 06:50 PM, Michael Moore wrote:
|Free forum by Nabble||Edit this page|