You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Lon Varscsak <lo...@gmail.com> on 2016/05/18 22:23:36 UTC

Wicket Validation

Hey guys,

I have some business logic where when the set method is called, it first
validates the value.  In finding a “bad” value, it then throws a custom
validation exception.  We use this pattern all over the place.

Is there some way to handle this situation so that it’s a valid wicket
validation error?

Thanks for any tips.

-Lon (Wicket Newb :D)

Re: Wicket Validation

Posted by Lon Varscsak <lo...@gmail.com>.
Ah cool, I’ll give that a whirl.

-Lon

On Thu, May 19, 2016 at 9:55 AM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> IComponentAssignedModel?
>
> On Thu, May 19, 2016 at 6:52 PM, Lon Varscsak <lo...@gmail.com>
> wrote:
>
> > Hey Sven, I considered this, but realized that models don’t have access
> to
> > the component, so I wasn’t sure how I would report the errors.  Any tips
> > would be appreciated.
> >
> > -Lon
> >
> > On Thu, May 19, 2016 at 7:08 AM, Sven Meier <sv...@meiers.net> wrote:
> >
> > > Hi,
> > >
> > > you could use a custom model wrapper catching your exceptions and
> > > reporting them as error messages.
> > >
> > > Have fun
> > > Sven
> > >
> > >
> > >
> > > On 19.05.2016 00:23, Lon Varscsak wrote:
> > >
> > >> Hey guys,
> > >>
> > >> I have some business logic where when the set method is called, it
> first
> > >> validates the value.  In finding a “bad” value, it then throws a
> custom
> > >> validation exception.  We use this pattern all over the place.
> > >>
> > >> Is there some way to handle this situation so that it’s a valid wicket
> > >> validation error?
> > >>
> > >> Thanks for any tips.
> > >>
> > >> -Lon (Wicket Newb :D)
> > >>
> > >>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
>

Re: Wicket Validation

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
IComponentAssignedModel?

On Thu, May 19, 2016 at 6:52 PM, Lon Varscsak <lo...@gmail.com>
wrote:

> Hey Sven, I considered this, but realized that models don’t have access to
> the component, so I wasn’t sure how I would report the errors.  Any tips
> would be appreciated.
>
> -Lon
>
> On Thu, May 19, 2016 at 7:08 AM, Sven Meier <sv...@meiers.net> wrote:
>
> > Hi,
> >
> > you could use a custom model wrapper catching your exceptions and
> > reporting them as error messages.
> >
> > Have fun
> > Sven
> >
> >
> >
> > On 19.05.2016 00:23, Lon Varscsak wrote:
> >
> >> Hey guys,
> >>
> >> I have some business logic where when the set method is called, it first
> >> validates the value.  In finding a “bad” value, it then throws a custom
> >> validation exception.  We use this pattern all over the place.
> >>
> >> Is there some way to handle this situation so that it’s a valid wicket
> >> validation error?
> >>
> >> Thanks for any tips.
> >>
> >> -Lon (Wicket Newb :D)
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>



-- 
Regards - Ernesto Reinaldo Barreiro

Re: Wicket Validation

Posted by Lon Varscsak <lo...@gmail.com>.
Hey Sven, I considered this, but realized that models don’t have access to
the component, so I wasn’t sure how I would report the errors.  Any tips
would be appreciated.

-Lon

On Thu, May 19, 2016 at 7:08 AM, Sven Meier <sv...@meiers.net> wrote:

> Hi,
>
> you could use a custom model wrapper catching your exceptions and
> reporting them as error messages.
>
> Have fun
> Sven
>
>
>
> On 19.05.2016 00:23, Lon Varscsak wrote:
>
>> Hey guys,
>>
>> I have some business logic where when the set method is called, it first
>> validates the value.  In finding a “bad” value, it then throws a custom
>> validation exception.  We use this pattern all over the place.
>>
>> Is there some way to handle this situation so that it’s a valid wicket
>> validation error?
>>
>> Thanks for any tips.
>>
>> -Lon (Wicket Newb :D)
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Wicket Validation

Posted by Sven Meier <sv...@meiers.net>.
Hi,

you could use a custom model wrapper catching your exceptions and 
reporting them as error messages.

Have fun
Sven


On 19.05.2016 00:23, Lon Varscsak wrote:
> Hey guys,
>
> I have some business logic where when the set method is called, it first
> validates the value.  In finding a \u201cbad\u201d value, it then throws a custom
> validation exception.  We use this pattern all over the place.
>
> Is there some way to handle this situation so that it\u2019s a valid wicket
> validation error?
>
> Thanks for any tips.
>
> -Lon (Wicket Newb :D)
>


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


Re: Wicket Validation

Posted by Lon Varscsak <lo...@gmail.com>.
Hey Martin, well the exception is being thrown during the form submit
processing, but it just ends up as a big error on the page.

On Thu, May 19, 2016 at 12:00 AM, Martin Grigorov <mg...@apache.org>
wrote:

> Hi,
>
> Wicket cares about validation errors only during form submit processing.
> In your case you could throw ConversionException during the 'convertInput'
> phase.
> I.e. in the beginning of the form submit processing Wicket will try to
> convert the String input to the backend object (e.g. a String to Integer,
> or to a Date, or to something custom).
> If the setters are used at that time and the input is not valid then throw
> ConversionException.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Thu, May 19, 2016 at 12:23 AM, Lon Varscsak <lo...@gmail.com>
> wrote:
>
> > Hey guys,
> >
> > I have some business logic where when the set method is called, it first
> > validates the value.  In finding a “bad” value, it then throws a custom
> > validation exception.  We use this pattern all over the place.
> >
> > Is there some way to handle this situation so that it’s a valid wicket
> > validation error?
> >
> > Thanks for any tips.
> >
> > -Lon (Wicket Newb :D)
> >
>

Re: Wicket Validation

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Wicket cares about validation errors only during form submit processing.
In your case you could throw ConversionException during the 'convertInput'
phase.
I.e. in the beginning of the form submit processing Wicket will try to
convert the String input to the backend object (e.g. a String to Integer,
or to a Date, or to something custom).
If the setters are used at that time and the input is not valid then throw
ConversionException.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, May 19, 2016 at 12:23 AM, Lon Varscsak <lo...@gmail.com>
wrote:

> Hey guys,
>
> I have some business logic where when the set method is called, it first
> validates the value.  In finding a “bad” value, it then throws a custom
> validation exception.  We use this pattern all over the place.
>
> Is there some way to handle this situation so that it’s a valid wicket
> validation error?
>
> Thanks for any tips.
>
> -Lon (Wicket Newb :D)
>