Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Complex validation on List

Alex Wibowo

2007-03-07


Hi...

I am trying to use validation annotation to achieve the following:

1. I have a Java bean "aBean" in my action class, and it has a
java.util.List<AnItem> as its property.
2. AnItem has the structure as follow:
  AnItem{
      private String name;
      private int quantity;
       ... // getter & setters
  }


My question are as follow:
- How can I perform validation on this Java bean? Say, I need  "name" to be
a required field.
The only solution that I can think of, is to use @ExpressionValidator,
which points to a method
that do the validation programmatically. The same goes with "quantity"...
it must be an integer
- Complex validation that involves both "name" and "quantity". Say.. where
"quantity" is specified,
the "name" has to be specified as well. Again, the only solution I can
think of is to use @ExpressionValidator


Thanks in advance!

--
Best regards,


WiB
-------------------
©2008 junlu.com - Jax Systems, LLC, U.S.A.