Lets see the code about 'adding elements by pressing on a button'.  The
'getValue()' method is returning the value from the list box's HTTP
submitted values, if the add button is submitting values via ajax or some
other means then it may need a different approach.

-Clint

On Sun, May 1, 2011 at 8:15 PM, Coleman, Chris <
chris.cole...@thalesgroup.com.au> wrote:

> We have an app that allows people to add elements to a ListMultipleChoice
> by pressing on a button. We want the form to fail validation if the
> ListMultipleChoice contains no elements.
>
> I've tried this:
>
>  targettedSetsList.add(new IValidator()
>  {
>    public void validate(IValidatable validatable) {
>      // Always contains no items - strange
>      Collection list = (Collection)validatable.getValue();
>
>      if ( list.size() == 0 ) {
>        ValidationError ve = new ValidationError();
>        ve.setMessage("No sets have been specified for deployment");
>        validatable.error(ve);
>      }
>    }
>  });
>
> but at validation the list.size() is always 0 even if the user has added
> elements. Am I doing it the right way? Is there a better way?
>
>
>
>
> DISCLAIMER:---------------------------------------------------------------------------
> This e-mail transmission and any documents, files and previous e-mail
> messages
> attached to it are private and confidential. They may contain proprietary
> or copyright
> material or information that is subject to legal professional privilege.
> They are for
> the use of the intended recipient only.  Any unauthorised viewing, use,
> disclosure,
> copying, alteration, storage or distribution of, or reliance on, this
> message is
> strictly prohibited. No part may be reproduced, adapted or transmitted
> without the
> written permission of the owner. If you have received this transmission in
> error, or
> are not an authorised recipient, please immediately notify the sender by
> return email,
> delete this message and all copies from your e-mail system, and destroy any
> printed
> copies. Receipt by anyone other than the intended recipient should not be
> deemed a
> waiver of any privilege or protection. Thales Australia does not warrant or
> represent
> that this e-mail or any documents, files and previous e-mail messages
> attached are
> error or virus free.
>
> --------------------------------------------------------------------------------------
>
>

Reply via email to