You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Koen Molkenboer <ko...@gmail.com> on 2006/12/13 11:58:43 UTC

Custom converter and custom error message wicket 2.0

If you are creating a custom converter in wicket 2.0, you just implement the
IConverter interface, use the converter in your formcomponent, etc.

When the form is submitted the
wicket.markup.html.form.FormComponent#convert() method will be called. If
you configurated your custom converter the right way, the convertToObject()
method on your custom converter will be called. In this method you should
throw a ConversionException if the converter cannot convert the input to the
specified type. When this exception is thrown it will be caught in the
wicket.markup.html.form.FormComponent#convert() method, a validation error
is created with message key 'TypeValidator' or 'TypeValidator.classname'. 

I would like to have the possibility to assign to custom message key to that
validation error. Because there are situations that you have different
converters which converts a String to (for example) a Double with different
error messages.

 
-- 
View this message in context: http://www.nabble.com/Custom-converter-and-custom-error-message-wicket-2.0-tf2813302.html#a7850871
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: Custom converter and custom error message wicket 2.0

Posted by Johan Compagner <jc...@gmail.com>.
I just did this.
So if you get a fresh copy from svn you should have the code.

johan


On 12/13/06, Koen Molkenboer <ko...@gmail.com> wrote:
>
>
> Yes, you are right, it is used as well in the convert method. May be we
> need
> to wait when they synchronize the 1.x and 2.0 code.
>
>
>
> Johan Compagner wrote:
> >
> > in 1.3 this is already possible i see..
> >
> > ConversionException.setResourceKey(String resourceKey)
> >     {
> >         this.resourceKey = resourceKey;
> >     }
> >
> > johan
> >
> >
> > On 12/13/06, Johan Compagner <jc...@gmail.com> wrote:
> >>
> >> yeah we should add support that you can throw an ConversionException
> with
> >> the preferred key already set in it.
> >>
> >> can you add a feature request for this in jira?
> >>
> >> johan
> >>
> >>
> >>
> >> On 12/13/06, Koen Molkenboer <ko...@gmail.com> wrote:
> >> >
> >> >
> >> > If you are creating a custom converter in wicket 2.0, you just
> >> implement
> >> > the
> >> > IConverter interface, use the converter in your formcomponent, etc.
> >> >
> >> > When the form is submitted the
> >> > wicket.markup.html.form.FormComponent#convert () method will be
> called.
> >> > If
> >> > you configurated your custom converter the right way, the
> >> > convertToObject()
> >> > method on your custom converter will be called. In this method you
> >> > should
> >> > throw a ConversionException if the converter cannot convert the input
> >> to
> >> > the
> >> > specified type. When this exception is thrown it will be caught in
> the
> >> > wicket.markup.html.form.FormComponent#convert() method, a validation
> >> > error
> >> > is created with message key 'TypeValidator' or
> >> 'TypeValidator.classname'.
> >> >
> >> > I would like to have the possibility to assign to custom message key
> to
> >> > that
> >> > validation error. Because there are situations that you have
> different
> >> > converters which converts a String to (for example) a Double with
> >> > different
> >> > error messages.
> >> >
> >> >
> >> > --
> >> > View this message in context:
> >>
> http://www.nabble.com/Custom-converter-and-custom-error-message-wicket-2.0-tf2813302.html#a7850871
> >> >
> >> > Sent from the Wicket - Dev mailing list archive at Nabble.com.
> >> >
> >> >
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Custom-converter-and-custom-error-message-wicket-2.0-tf2813302.html#a7852836
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>

Re: Custom converter and custom error message wicket 2.0

Posted by Koen Molkenboer <ko...@gmail.com>.
Yes, you are right, it is used as well in the convert method. May be we need
to wait when they synchronize the 1.x and 2.0 code.



Johan Compagner wrote:
> 
> in 1.3 this is already possible i see..
> 
> ConversionException.setResourceKey(String resourceKey)
>     {
>         this.resourceKey = resourceKey;
>     }
> 
> johan
> 
> 
> On 12/13/06, Johan Compagner <jc...@gmail.com> wrote:
>>
>> yeah we should add support that you can throw an ConversionException with
>> the preferred key already set in it.
>>
>> can you add a feature request for this in jira?
>>
>> johan
>>
>>
>>
>> On 12/13/06, Koen Molkenboer <ko...@gmail.com> wrote:
>> >
>> >
>> > If you are creating a custom converter in wicket 2.0, you just
>> implement
>> > the
>> > IConverter interface, use the converter in your formcomponent, etc.
>> >
>> > When the form is submitted the
>> > wicket.markup.html.form.FormComponent#convert () method will be called.
>> > If
>> > you configurated your custom converter the right way, the
>> > convertToObject()
>> > method on your custom converter will be called. In this method you
>> > should
>> > throw a ConversionException if the converter cannot convert the input
>> to
>> > the
>> > specified type. When this exception is thrown it will be caught in the
>> > wicket.markup.html.form.FormComponent#convert() method, a validation
>> > error
>> > is created with message key 'TypeValidator' or
>> 'TypeValidator.classname'.
>> >
>> > I would like to have the possibility to assign to custom message key to
>> > that
>> > validation error. Because there are situations that you have different
>> > converters which converts a String to (for example) a Double with
>> > different
>> > error messages.
>> >
>> >
>> > --
>> > View this message in context:
>> http://www.nabble.com/Custom-converter-and-custom-error-message-wicket-2.0-tf2813302.html#a7850871
>> >
>> > Sent from the Wicket - Dev mailing list archive at Nabble.com.
>> >
>> >
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Custom-converter-and-custom-error-message-wicket-2.0-tf2813302.html#a7852836
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: Custom converter and custom error message wicket 2.0

Posted by Johan Compagner <jc...@gmail.com>.
in 1.3 this is already possible i see..

ConversionException.setResourceKey(String resourceKey)
    {
        this.resourceKey = resourceKey;
    }

johan


On 12/13/06, Johan Compagner <jc...@gmail.com> wrote:
>
> yeah we should add support that you can throw an ConversionException with
> the preferred key already set in it.
>
> can you add a feature request for this in jira?
>
> johan
>
>
>
> On 12/13/06, Koen Molkenboer <ko...@gmail.com> wrote:
> >
> >
> > If you are creating a custom converter in wicket 2.0, you just implement
> > the
> > IConverter interface, use the converter in your formcomponent, etc.
> >
> > When the form is submitted the
> > wicket.markup.html.form.FormComponent#convert () method will be called.
> > If
> > you configurated your custom converter the right way, the
> > convertToObject()
> > method on your custom converter will be called. In this method you
> > should
> > throw a ConversionException if the converter cannot convert the input to
> > the
> > specified type. When this exception is thrown it will be caught in the
> > wicket.markup.html.form.FormComponent#convert() method, a validation
> > error
> > is created with message key 'TypeValidator' or 'TypeValidator.classname'.
> >
> > I would like to have the possibility to assign to custom message key to
> > that
> > validation error. Because there are situations that you have different
> > converters which converts a String to (for example) a Double with
> > different
> > error messages.
> >
> >
> > --
> > View this message in context: http://www.nabble.com/Custom-converter-and-custom-error-message-wicket-2.0-tf2813302.html#a7850871
> >
> > Sent from the Wicket - Dev mailing list archive at Nabble.com.
> >
> >
>

Re: Custom converter and custom error message wicket 2.0

Posted by Johan Compagner <jc...@gmail.com>.
yeah we should add support that you can throw an ConversionException with
the preferred key already set in it.

can you add a feature request for this in jira?

johan



On 12/13/06, Koen Molkenboer <ko...@gmail.com> wrote:
>
>
> If you are creating a custom converter in wicket 2.0, you just implement
> the
> IConverter interface, use the converter in your formcomponent, etc.
>
> When the form is submitted the
> wicket.markup.html.form.FormComponent#convert() method will be called. If
> you configurated your custom converter the right way, the
> convertToObject()
> method on your custom converter will be called. In this method you should
> throw a ConversionException if the converter cannot convert the input to
> the
> specified type. When this exception is thrown it will be caught in the
> wicket.markup.html.form.FormComponent#convert() method, a validation error
> is created with message key 'TypeValidator' or 'TypeValidator.classname'.
>
> I would like to have the possibility to assign to custom message key to
> that
> validation error. Because there are situations that you have different
> converters which converts a String to (for example) a Double with
> different
> error messages.
>
>
> --
> View this message in context:
> http://www.nabble.com/Custom-converter-and-custom-error-message-wicket-2.0-tf2813302.html#a7850871
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>