You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Peter Dotchev <do...@gmail.com> on 2009/04/28 22:40:00 UTC

Data validation and form components

Hi,

Setter methods of my business logic classes perform validation and throw 
exceptions if given parameter is invalid.
I don't have separate methods for data validation.
In my wicket form I use CompoundPropertyModel which sets user entered 
values directly in the business object.
If the user enters invalid value, the setter method throws some 
exception and the error page is shown.
How can I intercept this exception and show the error message in a 
feedback panel keeping the form open?

Best regards,
Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Data validation and form components

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Many folks on this list will disagree with you.  For most CRUD
applications, it is perfectly acceptable to directly manipulate domain
objects from forms.  For these applications, there is no reason to
maintain a separate set of value transfer objects.  The ROI isn't high
enough.  Of course, there are some applications where that need is
worth the cost.  I'm just saying that for most, it is not.

This case may very well be one that is worth the DTO.

--
Jeremy Thomerson
http://www.wickettraining.com




On Tue, Apr 28, 2009 at 3:57 PM, Mauro Ciancio <ma...@gmail.com> wrote:
> On Tue, Apr 28, 2009 at 5:40 PM, Peter Dotchev <do...@gmail.com> wrote:
>
>> Setter methods of my business logic classes perform validation and throw
>> exceptions if given parameter is invalid.
>> I don't have separate methods for data validation.
>> In my wicket form I use CompoundPropertyModel which sets user entered
>> values directly in the business object.
>> If the user enters invalid value, the setter method throws some exception
>> and the error page is shown.
>> How can I intercept this exception and show the error message in a feedback
>> panel keeping the form open?
>>
>
> Hi,
>  IMO isnt a great idea that your form directly modifies your business logic
> objects. You
> could use a pattern like Value Object. You modifies a Value Object and then
> updates
> your model with that Value Object.
>
> Cheers,
> --
> Mauro Ciancio
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Data validation and form components

Posted by Mauro Ciancio <ma...@gmail.com>.
On Tue, Apr 28, 2009 at 5:40 PM, Peter Dotchev <do...@gmail.com> wrote:

> Setter methods of my business logic classes perform validation and throw
> exceptions if given parameter is invalid.
> I don't have separate methods for data validation.
> In my wicket form I use CompoundPropertyModel which sets user entered
> values directly in the business object.
> If the user enters invalid value, the setter method throws some exception
> and the error page is shown.
> How can I intercept this exception and show the error message in a feedback
> panel keeping the form open?
>

Hi,
  IMO isnt a great idea that your form directly modifies your business logic
objects. You
could use a pattern like Value Object. You modifies a Value Object and then
updates
your model with that Value Object.

Cheers,
-- 
Mauro Ciancio