Re: Validation errors inside a sub-component
Re: Validation errors inside a sub-component
- Subject: Re: Validation errors inside a sub-component
- From: Pascal Robert <email@hidden>
- Date: Sat, 7 Nov 2009 22:50:10 -0500 (EST)
----- "Chuck Hill" <email@hidden> a écrit :
> On Nov 7, 2009, at 7:28 PM, Pascal Robert wrote:
>
> > Brain damage... My component superclass was doing this :
> >
> > public void awake() {
> > session().setErrors(new NSMutableArray<String>());
> > }
> >
> > So when SaveStatViewer was called, the array was empty...
>
> And you are not calling super.awake() :-)
Yeah, that too :-/ Now I just have to find out why WOText doesn't work but WOTextField do.
>
> >
> >> Maybe drop all your validation handling into your page component
> >> instead and then you can get at it with context.page? Extra
> bonus:
> >> use the same page super class everywhere and your validation
> handling
> >>
> >> is done in one place for your entire app. (^_^)
> >>
> >> Ramsey
> >>
> >> On Nov 5, 2009, at 9:12 PM, Pascal Robert wrote:
> >>
> >>> I'm trapping validation errors like this :
> >>>
> >>> private String error;
> >>>
> >>> public void validationFailedWithException(Throwable exception,
> >>> Object value, String keyPath) {
> >>> errors.addObject(exception.getMessage());
> >>> }
> >>>
> >>> public String error() {
> >>> return error;
> >>> }
> >>>
> >>> public void setError(String error) {
> >>> this.error = error;
> >>> }
> >>>
> >>> And in my component, I had this :
> >>>
> >>> <wo:AjaxUpdateContainer id = "saveState" fullSubmit = true>
> >>> <wo:ERXWOConditional condition = "$hasErrors">
> >>> <div class = "warning">
> >>> <p><wo:ERXLocalizedString value = "Errors.Header" />:</p>
> >>> <wo:WORepetition list = "$errors" item = "$error">
> >>> <wo:WOString value = "$error" escapeHTML = "false" />
> >>> <br />
> >>> </wo:WORepetition>
> >>> </div>
> >>> </wo:ERXWOConditional>
> >>> <wo:ERXElse>
> >>> <wo:WOString value = "$succesString" />
> >>> </wo:ERXElse>
> >>> </wo:AjaxUpdateContainer>
> >>>
> >>> That was working fine when this code was directly in my
> components,
> >>
> >>> but having the same stuff inside multiple components is not good,
> so
> >>
> >>> I moved this logic to a sub-component, and I'm calling this sub-
> >>> component from all my other components. Problem is, the sub-
> >>> component is called (if I put static text before the conditional,
> I
> >>
> >>> see it when I submit the form) but no errors are showing up and
> the
> >>
> >>> repetition don't iterate over the array. A breakpoint in
> >>> validationFailedWithException does show that the error is being
> >>> added to the array, so I have no idea on why it's not displaying
> >>> anything when it's in the sub-component.
> >>>
> >>> BTW, validationFailedWithException is inside a superclass that
> every
> >>
> >>> component inherits from.
> >>>
> >>> WO 5.4.3/ERExtensions from the current source.
> >>>
> >>> --
> >>>
> >>> -------------------------------------------------------
> >>> Pascal Robert
> >>>
> >>> http://www.macti.ca
> >>> http://www.linkedin.com/in/macti
> >>>
> >>> Skype: MacTICanada
> >>> AIM/iChat : MacTICanada
> >>> _______________________________________________
> >>> Do not post admin requests to the list. They will be ignored.
> >>> Webobjects-dev mailing list (email@hidden)
> >>> Help/Unsubscribe/Update your Subscription:
> >>> @mac.com
> >>>
> >>> This email sent to email@hidden
> >
> > --
> >
> > -------------------------------------------------------
> > Pascal Robert
> >
> > http://www.macti.ca
> > http://www.linkedin.com/in/macti
> >
> > Skype: MacTICanada
> > AIM/iChat : MacTICanada
> > _______________________________________________
> > Do not post admin requests to the list. They will be ignored.
> > Webobjects-dev mailing list (email@hidden)
> > Help/Unsubscribe/Update your Subscription:
> >
> >
> > This email sent to email@hidden
>
> --
> Chuck Hill Senior Consultant / VP Development
>
> Practical WebObjects - for developers who want to increase their
> overall knowledge of WebObjects or who are trying to solve specific
> problems.
> http://www.global-village.net/products/practical_webobjects
--
-------------------------------------------------------
Pascal Robert
http://www.macti.ca
http://www.linkedin.com/in/macti
Skype: MacTICanada
AIM/iChat : MacTICanada
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden