You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beehive.apache.org by djkuul <dh...@hotmail.com> on 2008/04/19 00:10:30 UTC

Validating indexed properties, nested properties...

One more question regarding validations-

How to validate indexed properties, nested properties and mapped properties?
Can this be done without writing a custom validator? Essentially I would
like to use the existing validation annotations like the 
Jpf.ValidateRequired, Jpf.ValidateEmail etc. but on indexed and nested
properties of an Action Form.

Thanks.
-- 
View this message in context: http://www.nabble.com/Validating-indexed-properties%2C-nested-properties...-tp16765604p16765604.html
Sent from the Beehive - User mailing list archive at Nabble.com.


Re: Validating indexed properties, nested properties...

Posted by djkuul <dh...@hotmail.com>.
I will try to elaborate the problem-

1. Department and Employee data is to be displayed to the User.
2. The ActionFormBean has an ArrayList of Department objects.
3. Each Department Object has an ArrayList of Employee Objects.
4. The user can modify Employee data for example- Salary (int).
5. The action method is decorated with appropriate validation annotations
say @Jpf.ValidateRequired.
6. Now to apply the Validate Required to the salary field of the Employee
object what should the propertyName of the @Jpf.ValidateRequired be set to?

Is it possible to do validations of indexed, nested and mapped properties
WITHOUT-
1. writing custom validations, so as to use the existing validations
provided by beehive.
2. without decorating the individual getter property with the validation
annotation, since we may not always be able to edit the Department and
Employee Classes.

Appreciate any suggestions/ thoughts...


djkuul wrote:
> 
> One more question regarding validations-
> 
> How to validate indexed properties, nested properties and mapped
> properties? Can this be done without writing a custom validator?
> Essentially I would like to use the existing validation annotations like
> the  Jpf.ValidateRequired, Jpf.ValidateEmail etc. but on indexed and
> nested properties of an Action Form.
> 
> Thanks.
> 

-- 
View this message in context: http://www.nabble.com/Validating-indexed-properties%2C-nested-properties...-tp16765604p16810243.html
Sent from the Beehive - User mailing list archive at Nabble.com.


Re: Validating indexed properties, nested properties...

Posted by Carlin Rogers <ca...@gmail.com>.
Hi Dj,

Unfortunately, in your case I think you're correct and will have to
use something like the custom validator. The netui-sample in the
distribution includes a page flow that uses a custom validator.

Kind regards,
Carlin

On Mon, Apr 21, 2008 at 6:02 PM, djkuul <dh...@hotmail.com> wrote:
>
>  Thanks Carlin, Nested properties do work.
>
>  Indexed properties did not work, and hence neither do nested indexed
>  properties (which I am really intrested in).
>  Databinding in jsp is not a problem for indexed properties since we can
>  easily do so using one of the
>  netui-data tags such as repeater or data grid and then use the container
>  implicit variable. But no 'iterating' facility is present when we want to do
>  the validation using the validation annotations.
>
>  What can be the best possible workaround?
>
>  Thanks,
>  Dj
>
>
>
>
>  Carlin Rogers-2 wrote:
>  >
>  > I haven't tested indexed properties but do know that nested properties
>  > work. To set up declarative validation to validate the properties of a
>  > nested form bean, the propertyName in the validation is given as
>  > something like "address.street". For example, it might look like...
>  >
>  >     @Jpf.Action(
>  >         useFormBean = "_formOne",
>  >         validatableProperties = {
>  >             @Jpf.ValidatableProperty(
>  >                 propertyName = "name",
>  >                 validateMinLength =
>  >                     @Jpf.ValidateMinLength(
>  >                         chars = 2,
>  >                         message = "Name must be 2 chars"
>  >                     )
>  >             ),
>  >             @Jpf.ValidatableProperty(
>  >                 propertyName = "address.street",
>  >                 validateMinLength =
>  >                     @Jpf.ValidateMinLength(
>  >                         chars = 5,
>  >                         message = "Street must be 5 chars"
>  >                     )
>  >             ),
>  >             @Jpf.ValidatableProperty(
>  >                 propertyName = "address.state",
>  >                 validateMinLength =
>  >                     @Jpf.ValidateMinLength(
>  >                         chars = 2,
>  >                         message = "State abbreviation must be 2 chars"
>  >                     ),
>  >                 validateMaxLength =
>  >                     @Jpf.ValidateMaxLength(
>  >                         chars = 2,
>  >                         message = "State abbreviation must be 2 chars"
>  >                     )
>  >             )
>  >
>  > And the corresponding JSP would have a dataSource for the same
>  > "address.street", etc...
>  >
>  >   Name: <netui:textBox dataSource="actionForm.name" /><br />
>  >   Street: <netui:textBox dataSource="actionForm.address.street" /><br />
>  >   State: <netui:textBox dataSource="actionForm.address.state" /><br />
>  >
>  > Kind regards,
>  > Carlin
>  >
>  >
>  > On Fri, Apr 18, 2008 at 4:10 PM, djkuul <dh...@hotmail.com> wrote:
>  >>
>  >>  One more question regarding validations-
>  >>
>  >>  How to validate indexed properties, nested properties and mapped
>  >> properties?
>  >>  Can this be done without writing a custom validator? Essentially I would
>  >>  like to use the existing validation annotations like the
>  >>  Jpf.ValidateRequired, Jpf.ValidateEmail etc. but on indexed and nested
>  >>  properties of an Action Form.
>  >>
>  >>  Thanks.
>  >>  --
>  >>  View this message in context:
>  >> http://www.nabble.com/Validating-indexed-properties%2C-nested-properties...-tp16765604p16765604.html
>  >>  Sent from the Beehive - User mailing list archive at Nabble.com.
>  >>
>  >>
>  >
>  >
>
>  --
>  View this message in context: http://www.nabble.com/Validating-indexed-properties%2C-nested-properties...-tp16765604p16818571.html
>
>
> Sent from the Beehive - User mailing list archive at Nabble.com.
>
>

Re: Validating indexed properties, nested properties...

Posted by djkuul <dh...@hotmail.com>.
Thanks Carlin, Nested properties do work.

Indexed properties did not work, and hence neither do nested indexed
properties (which I am really intrested in).
Databinding in jsp is not a problem for indexed properties since we can
easily do so using one of the 
netui-data tags such as repeater or data grid and then use the container
implicit variable. But no 'iterating' facility is present when we want to do
the validation using the validation annotations.

What can be the best possible workaround?

Thanks,
Dj


Carlin Rogers-2 wrote:
> 
> I haven't tested indexed properties but do know that nested properties
> work. To set up declarative validation to validate the properties of a
> nested form bean, the propertyName in the validation is given as
> something like "address.street". For example, it might look like...
> 
>     @Jpf.Action(
>         useFormBean = "_formOne",
>         validatableProperties = {
>             @Jpf.ValidatableProperty(
>                 propertyName = "name",
>                 validateMinLength =
>                     @Jpf.ValidateMinLength(
>                         chars = 2,
>                         message = "Name must be 2 chars"
>                     )
>             ),
>             @Jpf.ValidatableProperty(
>                 propertyName = "address.street",
>                 validateMinLength =
>                     @Jpf.ValidateMinLength(
>                         chars = 5,
>                         message = "Street must be 5 chars"
>                     )
>             ),
>             @Jpf.ValidatableProperty(
>                 propertyName = "address.state",
>                 validateMinLength =
>                     @Jpf.ValidateMinLength(
>                         chars = 2,
>                         message = "State abbreviation must be 2 chars"
>                     ),
>                 validateMaxLength =
>                     @Jpf.ValidateMaxLength(
>                         chars = 2,
>                         message = "State abbreviation must be 2 chars"
>                     )
>             )
> 
> And the corresponding JSP would have a dataSource for the same
> "address.street", etc...
> 
>   Name: <netui:textBox dataSource="actionForm.name" /><br />
>   Street: <netui:textBox dataSource="actionForm.address.street" /><br />
>   State: <netui:textBox dataSource="actionForm.address.state" /><br />
> 
> Kind regards,
> Carlin
> 
> 
> On Fri, Apr 18, 2008 at 4:10 PM, djkuul <dh...@hotmail.com> wrote:
>>
>>  One more question regarding validations-
>>
>>  How to validate indexed properties, nested properties and mapped
>> properties?
>>  Can this be done without writing a custom validator? Essentially I would
>>  like to use the existing validation annotations like the
>>  Jpf.ValidateRequired, Jpf.ValidateEmail etc. but on indexed and nested
>>  properties of an Action Form.
>>
>>  Thanks.
>>  --
>>  View this message in context:
>> http://www.nabble.com/Validating-indexed-properties%2C-nested-properties...-tp16765604p16765604.html
>>  Sent from the Beehive - User mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Validating-indexed-properties%2C-nested-properties...-tp16765604p16818571.html
Sent from the Beehive - User mailing list archive at Nabble.com.


Re: Validating indexed properties, nested properties...

Posted by Carlin Rogers <ca...@gmail.com>.
I haven't tested indexed properties but do know that nested properties
work. To set up declarative validation to validate the properties of a
nested form bean, the propertyName in the validation is given as
something like "address.street". For example, it might look like...

    @Jpf.Action(
        useFormBean = "_formOne",
        validatableProperties = {
            @Jpf.ValidatableProperty(
                propertyName = "name",
                validateMinLength =
                    @Jpf.ValidateMinLength(
                        chars = 2,
                        message = "Name must be 2 chars"
                    )
            ),
            @Jpf.ValidatableProperty(
                propertyName = "address.street",
                validateMinLength =
                    @Jpf.ValidateMinLength(
                        chars = 5,
                        message = "Street must be 5 chars"
                    )
            ),
            @Jpf.ValidatableProperty(
                propertyName = "address.state",
                validateMinLength =
                    @Jpf.ValidateMinLength(
                        chars = 2,
                        message = "State abbreviation must be 2 chars"
                    ),
                validateMaxLength =
                    @Jpf.ValidateMaxLength(
                        chars = 2,
                        message = "State abbreviation must be 2 chars"
                    )
            )

And the corresponding JSP would have a dataSource for the same
"address.street", etc...

  Name: <netui:textBox dataSource="actionForm.name" /><br />
  Street: <netui:textBox dataSource="actionForm.address.street" /><br />
  State: <netui:textBox dataSource="actionForm.address.state" /><br />

Kind regards,
Carlin


On Fri, Apr 18, 2008 at 4:10 PM, djkuul <dh...@hotmail.com> wrote:
>
>  One more question regarding validations-
>
>  How to validate indexed properties, nested properties and mapped properties?
>  Can this be done without writing a custom validator? Essentially I would
>  like to use the existing validation annotations like the
>  Jpf.ValidateRequired, Jpf.ValidateEmail etc. but on indexed and nested
>  properties of an Action Form.
>
>  Thanks.
>  --
>  View this message in context: http://www.nabble.com/Validating-indexed-properties%2C-nested-properties...-tp16765604p16765604.html
>  Sent from the Beehive - User mailing list archive at Nabble.com.
>
>