how to register IConverters

View: New views
4 Messages — Rating Filter:   Alert me  

how to register IConverters

by lars vonk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I need to use a custom implementation of an IConverter. The way I see
to let the application use this class is to:

- override method newConverterLocator
- return own implementation of IConverterLocater (or sublcass of
ConverterLocator) that registers the new IConverter.

Is this correct, because this seems a bit verbose?

Is it maybe an idea to change this to a registerConverter(IConverter)
method that I can call? That saves me a custom IConverterLocator to
implement.

Thanks, Lars

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


Re: how to register IConverters

by Timo Rantalaiho :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, 21 Jul 2008, lars vonk wrote:
> Is it maybe an idea to change this to a registerConverter(IConverter)
> method that I can call? That saves me a custom IConverterLocator to
> implement.

Normally you can just register converters in init() of your
Application subclass. You only need your own IConverterLocator
implementation if you want more specialised way of locating
converters than the default (for example, to support Hibernate
proxies).

Best wishes,
Timo

--
Timo Rantalaiho          
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

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


Re: how to register IConverters

by lars vonk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Timo,

thanks for replying.

> Normally you can just register converters in init() of your
> Application subclass.

How is this done? What method do I call? The only way I see to add
your own converters is the way I described previously or explicitly
cast the IConverterLocator an
org.apache.wicket.util.convert.ConverterLocator since there is no set
method on the IConverterLocator interface that allows to add
converters. Or am I overlooking something?

Thanks in advance,
Lars



On Wed, Jul 23, 2008 at 6:16 AM, Timo Rantalaiho <Timo.Rantalaiho@...> wrote:

> On Mon, 21 Jul 2008, lars vonk wrote:
>> Is it maybe an idea to change this to a registerConverter(IConverter)
>> method that I can call? That saves me a custom IConverterLocator to
>> implement.
>
> Normally you can just register converters in init() of your
> Application subclass. You only need your own IConverterLocator
> implementation if you want more specialised way of locating
> converters than the default (for example, to support Hibernate
> proxies).
>
> Best wishes,
> Timo
>
> --
> Timo Rantalaiho
> Reaktor Innovations Oy    <URL: http://www.ri.fi/ >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

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


Re: how to register IConverters

by Jason Lea :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We followed the wiki:  
http://cwiki.apache.org/WICKET/using-custom-converters.html
So in our Application class we have

    @Override
    protected IConverterLocator newConverterLocator() {
        final ConverterLocator converterLocator=new ConverterLocator();
        converterLocator.set(Long.class, new MyLongConverter());
        converterLocator.set(BigDecimal.class, new MyBigDecimalConverter());
        return converterLocator;
    }

We only had to create MyLongConverter and MyBigDecimalConverter, and
just used the existing ConverterLocator.  We only created the converters
so we could have longs and bigdecimals appear with digit groups eg
1,234,567.89

lars vonk wrote:

> Hi Timo,
>
> thanks for replying.
>
>  
>> Normally you can just register converters in init() of your
>> Application subclass.
>>    
>
> How is this done? What method do I call? The only way I see to add
> your own converters is the way I described previously or explicitly
> cast the IConverterLocator an
> org.apache.wicket.util.convert.ConverterLocator since there is no set
> method on the IConverterLocator interface that allows to add
> converters. Or am I overlooking something?
>
> Thanks in advance,
> Lars
>
>
>
> On Wed, Jul 23, 2008 at 6:16 AM, Timo Rantalaiho <Timo.Rantalaiho@...> wrote:
>  
>> On Mon, 21 Jul 2008, lars vonk wrote:
>>    
>>> Is it maybe an idea to change this to a registerConverter(IConverter)
>>> method that I can call? That saves me a custom IConverterLocator to
>>> implement.
>>>      
>> Normally you can just register converters in init() of your
>> Application subclass. You only need your own IConverterLocator
>> implementation if you want more specialised way of locating
>> converters than the default (for example, to support Hibernate
>> proxies).
>>
>> Best wishes,
>> Timo
>>
>> --
>> Timo Rantalaiho
>> Reaktor Innovations Oy    <URL: http://www.ri.fi/ >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@...
>> For additional commands, e-mail: users-help@...
>>
>>
>>    
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>
>  

--
Jason Lea


LightInTheBox - Buy quality products at wholesale price