ConversionError: The undefined value has no properties.
"Howk, Michael" <[email protected]>
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <DAE27F97B644D64FBF20945E0B1A05DA5F8735@mhxxfscexmb01.na.follett.lan> |
We're trying to run a javascript event through HttpUnit, and we keep
getting a Conversion Error: The undefined value has no properties. We've
turned off HttpUnitOptions.setExceptionsThrownOnScriptError, but we
really need this script to run. Here's the link we're trying to click:
<a href="javascript:generateReport()">
<img align="absbottom" src='/images/buttons/large/go.gif' border="0"
title='Go!' alt='Go!' name="generateReport" height="23" style="CURSOR:
hand"/>
</a>
And here is the function (and its supporting functions):
<script language="JavaScript" type="text/javascript">
<!--
function toHex8bit(n) {
return (enHex((0x0000f0 & n) >> 4) +
enHex((0x00000f & n) >> 0))
}
function destinyEscape(string) {
var result = "";
var i = 0;
for (i = 0; i < string.length; i++) {
c = string.charCodeAt(i);
if (c < 48) {
result = result + "%" + toHex8bit(c);
} else {
result = result + String.fromCharCode(c);
}
}
return result;
}
function generateReport() {
var reportType =
document.cataloging_servlet_BookListForm.reportType.value;
if (reportType == "0"){
generateCitationList();
} else {
generateBibliography();
}
}
function generateBibliography() {
//Set the variables dynamically based on the current values
on the form
var reportTitle =
document.cataloging_servlet_BookListForm.reportTitle.value;
var sortOrder =
document.cataloging_servlet_BookListForm.bibReportSortOptions.value;
var collectionType =
document.cataloging_servlet_BookListForm.collectionType.value;
var listID =
document.cataloging_servlet_BookListForm.listID.value;
var showNotes;
if (
document.cataloging_servlet_BookListForm.showNotes.checked) {
showNotes = "true";
} else {
showNotes = "false";
}
//Build the URL based on the fields in the form
var url =
'/cataloging/servlet/presentbibreportform.do?reportTitle=' +
destinyEscape(reportTitle) + '&sort=' + sortOrder + '&listID=' + listID
+ '&showNotes=' + showNotes + '&collectionType=' + collectionType;
//Open the new window
window.open(url, 'Bibliography').focus();
}
function generateCitationList() {
//Set the variables dynamically based on the current values
on the form
var reportTitle =
document.cataloging_servlet_BookListForm.reportTitle.value;
var collectionType =
document.cataloging_servlet_BookListForm.collectionType.value;
//Build the URL based on the fields in the form
var listID =
document.cataloging_servlet_BookListForm.listID.value;
if (collectionType == "0" || collectionType == "2") {
var url =
'/cataloging/servlet/presentcitationreportform.do?reportTitle=' +
destinyEscape(reportTitle) + '&collectionType=' + collectionType +
'&listID=' + listID;
} else {
var url =
'/cataloging/servlet/presentwebsitecitationreportform.do?reportTitle=' +
destinyEscape(reportTitle) + '&listID=' + listID;
}
//Open the new window
window.open(url, 'CitationList').focus();
}
// -->
</script>
We're calling the link like this:
...
WebLink link = table.getTableCell(0,0).getLinkWithImageText("Go!")
WebResponse result = null;
boolean worked =
link.getScriptableDelegate().doEvent(link.getURLString());
HttpClientListener listener = new HttpClientListener(wc);
result = link.click();
if (worked) {
result = listener.popResponse();
}
wc.removeClientListener(listener);
return result;
We recently updated HttpUnit from 1.5.3 to version 1.6.2. In the older
version, the variable "worked" would be true, and we could use our
custom Listener to pop the response and get the result of the event. But
now, we're getting the following error:
ConversionError: The undefined value has no properties. (httpunit; line
24)
at
org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:597
)
at
org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:557
)
at
org.mozilla.javascript.ScriptRuntime.getProp(ScriptRuntime.java:712)
at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2035)
at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2163)
at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java
:58)
at
com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.performEve
nt(JavaScript.java:172)
at
com.meterware.httpunit.scripting.ScriptableDelegate.doEvent(ScriptableDe
legate.java:56)
Please help!
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop