cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joost Kuif" <Joost.k...@mobillion.nl>
Subject RE: setting a validation error on another field
Date Thu, 09 Feb 2006 13:37:38 GMT
I use version 2.1.8..

-----Oorspronkelijk bericht-----
Van: Antonio Fiol BonnĂ­n [mailto:antonio.fiol@gmail.com] 
Verzonden: Thursday, February 09, 2006 2:00 PM
Aan: users@cocoon.apache.org
Onderwerp: Re: setting a validation error on another field

Apparently, the current code on svn for parent.validate() should
return false if any widget contained in parent (if parent is a group)
is not valid.

I did not check any previous versions, but if it does not return
false, could you please tell us what Cocoon version you are using?

--
Antonio Fiol


2006/2/9, Joost Kuif <Joost.kuif@mobillion.nl>:
> Andrew, thanks for your help. It's working, ALMOST..
>
> I simplified my first example as I use some groups with widgets (a
> multipage wizard from users perspective). The funny thing is that when I
> do the validation on the first group (page) and click 'next' I go to the
> activation (visability) of the second group.
> There doesn't seem to be a validation error. Then, when I click
> 'previous' and return to the first group, the validationerror is shown
> on the correct field. It looks like it is only a matter of stopping the
> flow to the next page. Something like setting or checking for a
> validationerror on the group...
>
> Does anyone know what to do to get this working?
> I really appreciate the help.
>
> Joost
>
> ------------------------------------------------------------------------
> -
> <fd:validation>
>         <fd:javascript>
>                 var form = this.getForm();
>                 var     bloggroup = form.getChild("page1");
>                 var blogshortcode = bloggroup.getChild("blogtitle");
>                 blogshortcode.setValidationError(new
> Packages.org.apache.cocoon.forms.validation.ValidationError("Error"));
>                 return false;
>         </fd:javascript>
> </fd:validation>
>
>
> The part with the logic where we go to the next group with widgets:
> ------------------------------------------------------------------------
> --
>
>                 <fd:action id="next">
>                         <fd:label><i18n:text
> i18n:key="createblog.next">Volgende</i18n:text></fd:label>
>                         <fd:on-action>
>                                 <fd:javascript>
>                                         var parent =
> event.source.parent;
>                                         if (parent.validate()) {
>
> parent.setState(WidgetState.INVISIBLE);
>                                                 var     blogchoice =
> this.lookupWidget("../blogchoice");
>
> java.lang.System.out.println("test op blogchoice : " +
> blogchoice.getValue().equals("personal"));
>                                                 if
> (!blogchoice.getValue().equals("blogroom")){
>
> parent.lookupWidget("../page3").setState(WidgetState.ACTIVE);
>                                                 } else {
>
> parent.lookupWidget("../page2").setState(WidgetState.ACTIVE);
>                                                 }
>                                         }
>                                 </fd:javascript>
>                         </fd:on-action>
>                 </fd:action>
>         </fd:widgets>
> </fd:group>
>
>
>
> -----Oorspronkelijk bericht-----
> Van: Andrew Timberlake [mailto:andrew@opensourcegroup.co.za]
> Verzonden: Thursday, February 09, 2006 9:59 AM
> Aan: users@cocoon.apache.org
> Onderwerp: Re: setting a validation error on another field
>
> Joost Kuif wrote:
> > Hi people,
> >
> >
> > I have a formdefinition with multiple fields. For some of these fields
> > uniqueness must be checked against a table in a database. I want to
> > check this towards the database with the use of one stored procedure.
> I
> > tried to with something like the example below, but this didn't work.
> > The page is left without a validation warning on the field. Does
> anyone
> > have an idea how to do setting of a validationerror of a field outside
> > of the field?
> >
> > <fd:field id="blogshortcode" required="true">
> > ...
> > <fd:validation>
> >  <javascript>
> >   //call stored procedure here and optionally
> >   //complain that anotherfield's value is already in use with:
> >
> widget.getParent().lookupWidget("anotherfield").setValidationError(new
> >
> Packages.org.apache.cocoon.forms.validation.ValidationError("not_unique"
> > ));
> >  </javascript>
> > </fd:validation>
> > </fd:field>
> >
> > <fd:field id="anotherfield" required="true">
> > ...
> > </fd:field>
> >
> >
> >
> > Any help would be appreciated.
> >
> > Joost
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
> I've done this as follows
> <fd:validation>
>      <fd:javascript>
>         if(determinValidation())
>         {
>              var form = widget.form;
>              form.lookupWidget('widget_name').setValicationError(new
> Packages.org.apache.cocoon.forms.validation.ValidationError('Error')
>              return false;
>          }
>      </fd:javascript>
> </fd:validation>
>
>
> The differences I see are:
> * using widget.form to locate the form object and then getting the other
>
> widget from the form.
> * adding the fd: to javascript
> * returning false to ensure the error is noted.
>
> Hope this helps
>
> Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message