opensubscriber
   Find in this group all groups
 
Unknown more information…

t : tapestry-user@jakarta.apache.org 1 May 2006 • 11:02AM -0400

Re: Conditional validation
by Nick Westgate

REPLY TO AUTHOR
 
REPLY TO GROUP




Hi Bianca.

I'm working in T3, but T4 still uses a validation delegate,
so perhaps this might be helpful to you.

To make things easier, I extended ValidationDelegate to add:


     public boolean isComponentInError(String componentName)
     {
         List trackings = getAssociatedTrackings();
         if (trackings != null)
         {
             Iterator i = (Iterator)trackings.iterator();
             while (i.hasNext())
             {
                 FieldTracking fieldTracking = (FieldTracking)i.next();
                 if (componentName.equals(fieldTracking.getFieldName()))
                 {
                     return fieldTracking.isInError();
                 }
             }
         }

         return false;
     }

     public void clearComponentErrors(String[] componentNamesClear)
     {
         List namesList = Arrays.asList(componentNamesClear);
         List trackings = getAssociatedTrackings();
         if (trackings != null)
         {
             Iterator i = (Iterator)trackings.iterator();
             while (i.hasNext())
             {
                 FieldTracking fieldTracking = (FieldTracking)i.next();
                 if (namesList.contains(fieldTracking.getFieldName()))
                 {
                     fieldTracking.setErrorRenderer(null);
                 }
             }
         }
     }

and other such helper functions.

Then you can build dependancy validation in your form submit listener.

Cheers,
Nick.


Bode, Bianca wrote:
> Hi all,
>
> I was wondering if anyone has ever done the following, and if so, how :)
>
> The situation is pretty complex, but basically it comes down to this:
> I want to validate an Insert component, but only if another component, a
> CheckBox, is checked...
>
> Anyone?
>
> Kind regards, Bianca.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jaka...
> For additional commands, e-mail: tapestry-user-help@jaka...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jaka...
For additional commands, e-mail: tapestry-user-help@jaka...

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.