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

Dr. Erich W. Schreiner commented on WICKET-2922:
------------------------------------------------

IMHO, changing the generics parameters on AutoCompleteTextField would break the 
interface and therefore only be possible for 1.5

Suggestion: create another class AutoCompleteTextFieldWithCustomRenderer<T,R> 
(extending TextField<T>) that allows to specify an IModel<T> (including a 
PropertyModel<String> as above) and to use a custom renderer / rendering model. 
This class would specify an abstract method getChoices(String input) that needs 
to return an Iterator<R>.

A subsequent and more risky change would be to refactor AutoCompleteTextField 
to extend this new class. Otherwise, lots of duplication (mostly the overloaded 
constructors) will arise. Since the refactored AutoCompleteTextField would 
still need all the constructors (then re-routed to call super()) this will not 
reduce but bloat the code...

> AutoCompleteTextField should allow the generics specification for the 
> getChoices iterator and the type of the model
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-2922
>                 URL: https://issues.apache.org/jira/browse/WICKET-2922
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-extensions
>    Affects Versions: 1.4.8
>            Reporter: Scott Hraban
>            Priority: Minor
>             Fix For: 1.4.10, 1.5-M1
>
>
> When using AutoCompleteTextField, and returning POJOs from the getChoices 
> override, and then rendering the POJO to text value through a 
> IAutoCompleteRenderer, unless you also provide a Converter to the component, 
> it is not possible to provide fully types parameters to the constructor.
> I.E.:
> new AutoCompleteTextField<MyPojo>("compoonentId", new 
> PropertyModel<String>(this, "myPojoName"), new MyPojoRenderer<MyPojo>())
> {
>     @Override
>     protected Iterator<MyPojo> getChoices(final String input) {
>         return getMyPojoChoices();
>     )
> }
> This will not compile, as the PropertyModel MUST be of type MyPojo, but 
> unless you provide a Converter to convert the text choice back to the POJO 
> instance, the model _cannot_ actually be of any type other than String.
> I would like to see AutoCompleteTextField to be changed so that you can type 
> it like:
> AutoCompleteTextField<MyPojo, MyPojo>
> AutoCompleteTextField<MyPojo, String>
> Depending on whether you are handling the conversion via a 
> getConverter(Class<?>) override, or outside the AutoCompleteTextField.

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

Reply via email to