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/03 23:12:54 UTC

[jira] Created: (WICKET-2658) Allow to overide DefaultConverter

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
            Priority: Minor


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.

Thanks for considering.

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


[jira] Updated: (WICKET-2658) Allow to overide DefaultConverter

Posted by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-2658?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ricardo Mayerhofer updated WICKET-2658:
---------------------------------------

    Attachment: ValueObjectConverter.java

> 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.


[jira] Resolved: (WICKET-2658) Allow to overide DefaultConverter

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-2658?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Johan Compagner resolved WICKET-2658.
-------------------------------------

    Resolution: Won't Fix
      Assignee: Johan Compagner

what is the problem with overriding:

protected IConverterLocator newConverterLocator()
	{
		return new ConverterLocator();
	}

in the application class?

> 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
>
> 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.


[jira] Commented: (WICKET-2658) Allow to overide DefaultConverter

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12796230#action_12796230 ] 

Johan Compagner commented on WICKET-2658:
-----------------------------------------

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;
} 

> 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.


[jira] Commented: (WICKET-2658) Allow to overide DefaultConverter

Posted by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12796177#action_12796177 ] 

Ricardo Mayerhofer commented on WICKET-2658:
--------------------------------------------

Hi Johan,
Thanks for your quick response. Currently if you need to use a different defaultconverter you have to write your own converter locator from ground up. That's done basically copying and pasting wicket's converter locator and changing defaultconverter, because there is no way to extend ConverterLocator.java (all methods are final and DefaultConverter is private). 
It would be easier if it were possible to to extend convertlocator and overide a newly created getDefaultLocator method, for example.

> 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
>
> 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.


[jira] Commented: (WICKET-2658) Allow to overide DefaultConverter

Posted by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12796228#action_12796228 ] 

Ricardo Mayerhofer commented on WICKET-2658:
--------------------------------------------

Yes is ugly  :) 
Regarding the proposed solution almost there. But then DefaultConverter (private class of ConverterLocator.java) converting strategy is never called.

> 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.


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

Posted by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Commented: (WICKET-2658) Allow to overide DefaultConverter

Posted by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12796190#action_12796190 ] 

Ricardo Mayerhofer commented on WICKET-2658:
--------------------------------------------

Perhaps I wasn't clear, I will try to explain it better.
When wicket is unable find a specific converter for a given class it calls DefaultConverter (private class of ConverterLocator.java). 
DefaultConverter handles the default converting strategy, usually handling primitives. I would like to append as a default converting strategy to try to instantiate the given class through constructor.  I'm attaching how it looks like.

This could be easily achieved if overide getDefaultConvert (or a similar method) in ConverterLocator.java were possible, and optimized if to extend DefaultConverter were possible (by extracting it to a separate class).



> 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.


[jira] Updated: (WICKET-2658) Allow to overide DefaultConverter

Posted by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-2658?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ricardo Mayerhofer updated WICKET-2658:
---------------------------------------

    Description: 
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.

  was:
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.

Thanks for considering.


> 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
>            Priority: Minor
>
> 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.


[jira] Commented: (WICKET-2658) Allow to overide DefaultConverter

Posted by "Ricardo Mayerhofer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12796260#action_12796260 ] 

Ricardo Mayerhofer commented on WICKET-2658:
--------------------------------------------

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.


[jira] Commented: (WICKET-2658) Allow to overide DefaultConverter

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12796210#action_12796210 ] 

Johan Compagner commented on WICKET-2658:
-----------------------------------------

and now you dont base your flow on exceptions (which i find kind of ugly)

> 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.


[jira] Commented: (WICKET-2658) Allow to overide DefaultConverter

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12796209#action_12796209 ] 

Johan Compagner commented on WICKET-2658:
-----------------------------------------

ahh so:

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


> 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.


[jira] Commented: (WICKET-2658) Allow to overide DefaultConverter

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12796180#action_12796180 ] 

Johan Compagner commented on WICKET-2658:
-----------------------------------------

Where is that parameter coming from exactly?

why wouldnt this work:

protected IConverterLocator newConverterLocator()
{
ConverterLocator locator = new ConverterLocator();
locator.set(ValueObject.class, new ValueObjectConverter());
return locator;
}

and then your ValueObjectConverter will get your parameter somehow?



> 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
>
> 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.