From: Jeff M. <jma...@ho...> - 2005-04-13 13:41:44
|
I deleted the reply that I received from Chris Erskine back in February regarding my original posting, but it is still listed in the user group archive. It can be found at: http://sourceforge.net/mailarchive/message.php?msg_id=10991620 This message contains the solution to that posting. As a refresher, here was the problem that I was getting at the time when I was executing a HtmlUnit test case against our code: org.mozilla.javascript.EvaluatorException: The undefined value has no properties After stepping through the source code for both Rhino and HtmlUnit, I found that the problem was related to how a method in the com.gargolyesoftware.htmlunit.javascript.FormElementArray was working with our choice of usage for a submit button. In other words, the JavaScript that was in the process of being executed via the Rhino stuff needed to get the related components from the HtmlUnit framework, and that's where the problem was happening. The specific JavaScript that was in the process of being executed was related to an onSubmit event, which was related to our submit button (in a form within a JSP). The thing is that we were using a org.apache.strutsel.taglib.html.ELSubmitTag from the Struts tag extension library for our submit button. The implementation for that tag and its ancestors does not appear to have a "name" attribute, which is fine as far as our application is concerned b/c it works without a hitch (we were using the "id" attribute instead). However, when trying to execute our code via the test framework, there is one point at which the FormElementArray class tries to get a handle to our submit button in the get(final String name, final Scriptable start) method. Within that method, it iterates through all of the form elements on the page from which the current request is being made. It gets these elements and tries to find a match for the attribute being used at the time, which for this specific example was the name of our button taken from this portion of JavaScript that was being executed: document.cmsForm.elements.sendButton.disabled = true; That is, it was trying to get our button ("sendButton") in this portion of the FormElementArray get() method: if( htmlElement.getAttributeValue("name").equals(name) ) { But, b/c we were using the Struts EL submit button, which doesn't support the "name" attribute, it wasn't being found as intended. So eventually what happens is that the code continues on and tries to find the "disabled" attribute for our button object, which is listed at that point as undefined. Hence the EvaluatorException that is seen, ultimately. I ended up changing our code like so to ensure our submit button would be found: <%-- <html-el:submit value="Send to CMS" styleClass="formFont" accesskey="s" styleId="sendButton"> </html-el:submit> --%> <input type="submit" value="Send to CMS" class="formFont" accesskey="s" name="sendButton" id="sendButton" /> That seems to work. Hopefully this will help others within the HtmlUnit user community and perhaps the development community as well. Jeff |