You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org> on 2010/01/04 18:45:55 UTC

[jira] Issue Comment Edited: (WICKET-2658) Allow to overide DefaultConverter

    [ https://issues.apache.org/jira/browse/WICKET-2658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12796260#action_12796260 ] 

Ricardo Mayerhofer edited comment on WICKET-2658 at 1/4/10 5:45 PM:
--------------------------------------------------------------------

It works. But if override were possible we could replace:

protected IConverterLocator newConverterLocator()
{
IConverterLocator locator = new IConverterLocator()
{
 ConverterLocator defaultLocator = new ConverterLocator();
ConstructorInstantiator instantiatior = new ConstructorInstantiator ();
 
 public IConverter getConverter(Class<?> type)
 {
        IConverter converter = defaultLocator.getConverter(type);
        if (type != null && default.get(type) == null) return new ValueObjectConverter(type,instantiatior, converter );
        return converter;
 }
}
return locator;
} 

by:

protected IConverterLocator newConverterLocator()
{
        IConverterLocator locator = new ConverterLocator()
        {
                IConverter getDefaultConverter() 
                {
                        return new ValueObjectConverter(type,new ConstructorInstantiator ());
                 }
        }
} 

Simpler, because otherwise we're replicating the logic that decides when to use Default Converter (if (type != null && default.get(type) == null) ), and have some boiler plate in place.



      was (Author: ricardo.ekm):
    It works. But if override were possible we could replace:

protected IConverterLocator newConverterLocator()
{
IConverterLocator locator = new IConverterLocator()
{
 ConverterLocator defaultLocator = new ConverterLocator();
ConstructorInstantiator instantiatior = new ConstructorInstantiator ();
 
 public IConverter getConverter(Class<?> type)
 {
        IConverter converter = defaultLocator.getConverter(type);
        if (type != null && default.get(type) == null) return new ValueObjectConverter(type,instantiatior, converter );
        return converter;
 }
}
return locator;
} 

by:

protected IConverterLocator newConverterLocator()
{
        IConverterLocator locator = new IConverterLocator()
        {
                IConverter getDefaultConverter() 
                {
                        return new ValueObjectConverter(type,new ConstructorInstantiator ());
                 }
        }
} 

Simpler, because otherwise we're replicating the logic that decides when to use Default Converter (if (type != null && default.get(type) == null) ), and have some boiler plate in place.


  
> Allow to overide DefaultConverter
> ---------------------------------
>
>                 Key: WICKET-2658
>                 URL: https://issues.apache.org/jira/browse/WICKET-2658
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>            Reporter: Ricardo Mayerhofer
>            Assignee: Johan Compagner
>            Priority: Minor
>         Attachments: ValueObjectConverter.java
>
>
> In a application with many value objects (from P of EAA) is useful as a conversion last resource to instantiate the target class passing the reveived parameter to class constructor. This can be achieved overiding ConverterLocator's default converter . 
> One way this could be done is:
> - Remove final from getConverterLocator() in Application.java, so one can implement its own converter locator.
> - ConverterLocator have a getDefaultLocator that could be overiden.
> I don't know if this is the best way, but it requires few changes in wicket.
> Thanks for considering.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.