struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <niall.pember...@gmail.com>
Subject Re: errorStyleClass not working
Date Fri, 21 Jul 2006 22:29:47 GMT
On 7/21/06, David Friedman <humble@ix.netcom.com> wrote:
> You should find out what version of the commons validator you are using.
> Notes from the Jakarts Commons Validator site shows that older versions may
> stop on the first error for INDEXED properties.  It sounds like your form
> uses and indexed property.  See notes like this:
> http://mail-archives.apache.org/mod_mbox/struts-user/200508.mbox/%3CE4CD19A7
> 78A1D511A48900A0C98E6028046D67D2@TCIOFMAIL%3E
>
> It seems that even the latest greatest stable version of Struts hasn't
> upgraded the jakarta commons validator to that high a level so you are
> probably best off trying to swap commons-validator.jar files and see if
> everything works right with your indexed properties.

Yes Struts 1.2.9 is distributed with Validator 1.1.4 - but you can
upgrade to the latest Validator 1.3.0 (upcoming Struts 1.3.5 has that
dependency) with Struts 1.2.9 which is what I have deployed.

Having said that Validator 1.3.0 won't resolve this issue for you
anyway - the only thing I know of is a small extension I wrote quite a
while ago that can do this:

http://www.niallp.pwp.blueyonder.co.uk/strutsvalidatorextends.html

Niall

> I'm out of ideas at this point so good luck (Unles Niall has any ideas).
>
> Regards,
> David
>
> -----Original Message-----
> From: fea jabi [mailto:zyxrm@hotmail.com]
> Sent: Friday, July 21, 2006 9:13 AM
> To: user@struts.apache.org
> Subject: RE: errorStyleClass not working
>
>
> I think the problem is on server side.
>
> As in the dispatch aciton, the below statement
> org.apache.struts.action.ActionErrors errors = frm.validate( mapping,
> request );
>
> is returning just one error even when the 2 entries entered by user are
> invalid. only after fixing the first the second error is getting
> highlighted.
>
>
> validation.xml
>
>    <formset>
>        <form name="Form" >
>            <field property="adHrs" indexedListProperty="hrs"
> depends="integer,validwhen">
>                <msg name="integer" key="lbl.notvalid"/>
>                <msg name="validwhen" key="lbl.notvalid"/>
>                <var>
>                    <var-name>test</var-name>
>                    <var-value>(*this* >= 0)</var-value>
>                </var>
>            </field>
>        </form>
>    </formset>
>
> I tried giving the below plug-in too. But it's the same. only one error gets
> highlighted. What else can I try to make all the errors get highlighted. Not
> sure why the validate is returning one one error when there are 2 entries
> that are invalid?
>
> Thanks.
>
>
> >From: "David Friedman" <humble@ix.netcom.com>
> >Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
> >To: "Struts Users Mailing List" <user@struts.apache.org>
> >Subject: RE: errorStyleClass not working
> >Date: Thu, 20 Jul 2006 17:23:48 -0400
> >
> >Is your problem server side or client side?  If you problem is client side
> >then you should read the struts javadocs:
> >
> >http://struts.apache.org/1.2.7/api/org/apache/struts/validator/ValidatorPlu
> g
> >In.html
> >
> >Or the User Guides:
> >http://struts.apache.org/1.x/faqs/validator.html
> >
> >Both of them mention a plugin property "stopOnFirstError":
> >
> ><plug-in className="org.apache.struts.validator.ValidatorPlugIn">
> >   <set-property property="pathnames"
> >    value="/WEB-INF/validator-rules.xml,/WEB-INF/validations.xml"/>
> >   <set-property property="stopOnFirstError" value="false"/>
> ></plug-in>
> >
> >*****
> >Also, if you want to use the errorStyleClass with your validation I think I
> >understand your problem now.  At the very bottom of this letter I left in a
> >copy of the code you described using in your dispatch action.  You save
> >errors with 'saveMessages(request, messages);' which presumably saves
> >messages in the Globals.MESSAGE_KEY.  If you switch to 'saveErrors(request,
> >messages);' then it will save them in the Globals.ERROR_KEY which is used
> >by
> >the errorStyleClass so it should be able to detect you have an ERROR and
> >automatically insert the html for "class='errorMsg'" whenever an error is
> >found.  For more information see this link where they talk about ERRORS and
> >MESSAGES being saved under different keys, as I've mentioned in my previous
> >posts:
> >http://struts.apache.org/1.x/struts-core/apidocs/org/apache/struts/action/A
> c
> >tion.html
> >
> >Regards,
> >David
> >
> > >On 7/19/06, fea jabi <zyxrm@hotmail.com> wrote:
> > >>Yah, in the JSP where the errorStyleClass is working I am using
> > >><html:errors
> > >>property="name"/>
> > >>
> > >>So, do I have to use html:errors? not html:messages?
> > >>
> > >>yes, I am using DynaValidatorForm but calling validate from action
> >class.
> > >>The validation is done in validator.xml
> > >>
> > >>In dispath action class I have
> > >>ActionMessages messages = (ActionMessages)frm.validate( mapping, request
> > >>);
> > >>         if ( messages != null && !messages.isEmpty() ) {
> > >>             saveMessages(request, messages);
> > >>             return (mapping.findForward("validationFailed"));
> > >>         }
> > >>
> > >>Should I be saving action errors instead of ActionMessages?
> > >>
> > >>Thanks.

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


Mime
View raw message