You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mitch Claborn <mi...@claborn.net> on 2009/08/30 00:17:52 UTC

ajax validation problem in IE8

Struts 2.1.6
I have a form that uses ajax validation before a non-ajax POST.  In IE8,
if the ajax validation call returns a field error (like a missing
field), I get the error in a pop up box in IE8: "An exception occurred:
Error. Error message: Invalid argument."

Only happens when there are field errors.  If there are no errors, all
is good.

Any ideas?

  <sx:submit formId="loginform" ajaxAfterValidation="false"
validate="true" value="sub ajax"
  type="image" src="%{imageServer}/continue_arrow.jpg"
  id="cont3" name="cont3" />



Mitch


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: ajax validation problem in IE8

Posted by Mitch Claborn <mi...@claborn.net>.
Some more info:  The generated HTML is below.

validation.js (in the css_xhtml theme) uses this line to find the
element before which to insert the new error div.
        var firstCtrNode = findWWCtrlNode(enclosingDiv); // either
wwctrl_ or wwlbl_
That function looks for a child div or span whose class matches "wwlbl"
or "wwctrl", or failing that the first span.  The generated HTML has
none of those, so firstCtrNode is undefined.  Later in validation.js is
        enclosingDiv.insertBefore(errorDiv, firstCtrNode);
When the last argument is undefined, FireFox simply inserts the errorDiv
at the end of the enclosingDiv, where IE8 complains.

So what's broken?  I've patched the .js file like this for now, but is
that the best solution?  Seems like since the code is written that way
that the templates should be generating a div or span that can be found.

My patch:
        var firstCtrNode = findWWCtrlNode(enclosingDiv); // either
wwctrl_ or wwlbl_
        if (! firstCtrNode) {
          // if we didn't find a node to insert before, use the first
child node
          firstCtrNode = enclosingDiv.firstChild;
          // if still didn't find one, simply do an alert and return
          // otherwise IE8 will complain - this should never happen
          if (! firstCtrNode) {
            alert(e);
            return;
          }
        }


My generated HTML:

<div id="wwgrp_loginform_address1" class="wwgrp">
<div id="wwctrl_loginform_address1" class="wwctrl">
<input type="text" name="address1" size="40" value=""
id="loginform_address1"/></div> </div>


Mitch

Dave Newton wrote:
> Martin Gainty wrote:
>> you can take all your JS scripts and run it thru RhinoScript
>> thats what i did for Dojo
>> http://www.rhinoscript.org
>>
>> be sure to toss in plenty of alert statements!
>
> What in the name of Bumba's porcelain alter are you talking about?
> Unless IE8 runs RhinoScript I don't see how that's going to help
> diagnose a browser-specific issue. Could you explain further?
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: ajax validation problem in IE8

Posted by Dave Newton <ne...@yahoo.com>.
Martin Gainty wrote:
> you can take all your JS scripts and run it thru RhinoScript
> thats what i did for Dojo
> http://www.rhinoscript.org
> 
> be sure to toss in plenty of alert statements!

What in the name of Bumba's porcelain alter are you talking about? 
Unless IE8 runs RhinoScript I don't see how that's going to help 
diagnose a browser-specific issue. Could you explain further?

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: ajax validation problem in IE8

Posted by Martin Gainty <mg...@hotmail.com>.
you can take all your JS scripts and run it thru RhinoScript
thats what i did for Dojo
http://www.rhinoscript.org

be sure to toss in plenty of alert statements!
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Sat, 29 Aug 2009 18:34:38 -0500
> From: mitch@claborn.net
> To: mgainty@hotmail.com; user@struts.apache.org
> Subject: Re: ajax validation problem in IE8
> 
> I'll give that a try.  I thought I remembered seeing instructions for a
> way to extract those .js files to somewhere so that I can put in some
> debugging statements.  Do you know about that?
> 
> Mitch
> 
> Martin Gainty wrote:
> > /template/css_xhtml/validation.js
> >
> > function addErrorCSS(e, errorText) {
> >     try {
> >         if (!e)
> >             return; //ignore errors for fields that are not in the form
> >         var elem = (e.type ? e : e[0]); //certain input types return
> > node list, while we single first node. I.e. set of radio buttons.
> >         var enclosingDiv = findWWGrpNode(elem); // find wwgrp div/span
> >
> >         //try to focus on first field
> >         var fieldPos = findFieldPosition(elem);
> >         if (fieldPos != null && (firstFieldErrorPosition == null ||
> > firstFieldErrorPosition > fieldPos)) {
> >             firstFieldErrorPosition = fieldPos;
> >         }
> >
> >         if (!enclosingDiv) {
> >             alert("Could not validate: " + e.id);
> >             return;
> >         }
> >        
> >         var label = enclosingDiv.getElementsByTagName("label")[0];
> >         if (label) {
> >             label.setAttribute("class", "errorLabel"); //standard
> > way.. works for ie mozilla
> >             label.setAttribute("className", "errorLabel"); //ie hack
> > cause ie does not support setAttribute
> >         }
> >
> >         var firstCtrNode = findWWCtrlNode(enclosingDiv); // either
> > wwctrl_ or wwlbl_
> >        
> >         var error = document.createTextNode(errorText);
> >         var errorDiv = document.createElement("div");
> >
> >         errorDiv.setAttribute("class", "errorMessage");//standard
> > way.. works for ie mozilla
> >         errorDiv.setAttribute("className", "errorMessage");//ie hack
> > cause ie does not support setAttribute
> >         errorDiv.setAttribute("errorFor", elem.id);
> >         errorDiv.appendChild(error);
> >         enclosingDiv.insertBefore(errorDiv, firstCtrNode);
> >     } catch (err) {
> >         alert("An exception occurred: " + err.name + ". Error message:
> > " + err.message);
> >     }
> > }
> >
> > i am assuming your theme="css_xhtml"
> >
> > appears to be an attribute misconfig with your div tag
> > i would comment out className attribute ..if that comes thru clean
> > then try the other attributes such ass
> > 'class' or 'errorFor'
> >
> > have you tried posting the error to IE8 forum
> >
> > http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.internetexplorer.general&tid=40cd8fd8-1631-4d95-8e9b-232d18ec8ba4&cat=en_us_28cca3eb-7037-4d4f-bde1-d8efee1f1420&lang=en&cr=us&sloc=&p=1
> >
> > ?
> > Martin Gainty
> > ______________________________________________
> > Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
> >  
> > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> > Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede
> > unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig.
> > Diese Nachricht dient lediglich dem Austausch von Informationen und
> > entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten
> > Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den
> > Inhalt uebernehmen.
> > Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> >
> >
> >
> >
> >
> > > Date: Sat, 29 Aug 2009 17:17:52 -0500
> > > From: mitch@claborn.net
> > > To: user@struts.apache.org
> > > Subject: ajax validation problem in IE8
> > >
> > > Struts 2.1.6
> > > I have a form that uses ajax validation before a non-ajax POST. In IE8,
> > > if the ajax validation call returns a field error (like a missing
> > > field), I get the error in a pop up box in IE8: "An exception occurred:
> > > Error. Error message: Invalid argument."
> > >
> > > Only happens when there are field errors. If there are no errors, all
> > > is good.
> > >
> > > Any ideas?
> > >
> > > <sx:submit formId="loginform" ajaxAfterValidation="false"
> > > validate="true" value="sub ajax"
> > > type="image" src="%{imageServer}/continue_arrow.jpg"
> > > id="cont3" name="cont3" />
> > >
> > >
> > >
> > > Mitch
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> >
> > ------------------------------------------------------------------------
> > With Windows Live, you can organize, edit, and share your photos.
> > Click here. <http://www.windowslive.com/Desktop/PhotoGallery>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Hotmail® is up to 70% faster. Now good news travels really fast. 
http://windowslive.com/online/hotmail?ocid=PID23391::T:WLMTAGL:ON:WL:en-US:WM_HYGN_faster:082009

Re: ajax validation problem in IE8

Posted by Mitch Claborn <mi...@claborn.net>.
I'll give that a try.  I thought I remembered seeing instructions for a
way to extract those .js files to somewhere so that I can put in some
debugging statements.  Do you know about that?

Mitch

Martin Gainty wrote:
> /template/css_xhtml/validation.js
>
> function addErrorCSS(e, errorText) {
>     try {
>         if (!e)
>             return; //ignore errors for fields that are not in the form
>         var elem = (e.type ? e : e[0]); //certain input types return
> node list, while we single first node. I.e. set of radio buttons.
>         var enclosingDiv = findWWGrpNode(elem); // find wwgrp div/span
>
>         //try to focus on first field
>         var fieldPos = findFieldPosition(elem);
>         if (fieldPos != null && (firstFieldErrorPosition == null ||
> firstFieldErrorPosition > fieldPos)) {
>             firstFieldErrorPosition = fieldPos;
>         }
>
>         if (!enclosingDiv) {
>             alert("Could not validate: " + e.id);
>             return;
>         }
>        
>         var label = enclosingDiv.getElementsByTagName("label")[0];
>         if (label) {
>             label.setAttribute("class", "errorLabel"); //standard
> way.. works for ie mozilla
>             label.setAttribute("className", "errorLabel"); //ie hack
> cause ie does not support setAttribute
>         }
>
>         var firstCtrNode = findWWCtrlNode(enclosingDiv); // either
> wwctrl_ or wwlbl_
>        
>         var error = document.createTextNode(errorText);
>         var errorDiv = document.createElement("div");
>
>         errorDiv.setAttribute("class", "errorMessage");//standard
> way.. works for ie mozilla
>         errorDiv.setAttribute("className", "errorMessage");//ie hack
> cause ie does not support setAttribute
>         errorDiv.setAttribute("errorFor", elem.id);
>         errorDiv.appendChild(error);
>         enclosingDiv.insertBefore(errorDiv, firstCtrNode);
>     } catch (err) {
>         alert("An exception occurred: " + err.name + ". Error message:
> " + err.message);
>     }
> }
>
> i am assuming your theme="css_xhtml"
>
> appears to be an attribute misconfig with your div tag
> i would comment out className attribute ..if that comes thru clean
> then try the other attributes such ass
> 'class' or 'errorFor'
>
> have you tried posting the error to IE8 forum
>
> http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.internetexplorer.general&tid=40cd8fd8-1631-4d95-8e9b-232d18ec8ba4&cat=en_us_28cca3eb-7037-4d4f-bde1-d8efee1f1420&lang=en&cr=us&sloc=&p=1
>
> ?
> Martin Gainty
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>  
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede
> unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig.
> Diese Nachricht dient lediglich dem Austausch von Informationen und
> entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten
> Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den
> Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
>
>
>
>
>
> > Date: Sat, 29 Aug 2009 17:17:52 -0500
> > From: mitch@claborn.net
> > To: user@struts.apache.org
> > Subject: ajax validation problem in IE8
> >
> > Struts 2.1.6
> > I have a form that uses ajax validation before a non-ajax POST. In IE8,
> > if the ajax validation call returns a field error (like a missing
> > field), I get the error in a pop up box in IE8: "An exception occurred:
> > Error. Error message: Invalid argument."
> >
> > Only happens when there are field errors. If there are no errors, all
> > is good.
> >
> > Any ideas?
> >
> > <sx:submit formId="loginform" ajaxAfterValidation="false"
> > validate="true" value="sub ajax"
> > type="image" src="%{imageServer}/continue_arrow.jpg"
> > id="cont3" name="cont3" />
> >
> >
> >
> > Mitch
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
> ------------------------------------------------------------------------
> With Windows Live, you can organize, edit, and share your photos.
> Click here. <http://www.windowslive.com/Desktop/PhotoGallery>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org