You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tron Walseth <tr...@telespor.no> on 2013/03/13 10:39:51 UTC

Deprecation of createLabelModel

Hi

A bit of advice is needed; 

The method createDataLabel of org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn is deprecated since 6.2.0, and the documentation advice is to use public IModel<Object> getDataModel(IModel<T> rowModel) instead. 

We have overridden this method in some places, and in most cases, the method returns a ResourceModel (IModel<String>). When fixing deprecation warnings by changing the method name, the compiler complains that the return type is not correct. 

The solution is fairly simple, just change the signature to 
            @SuppressWarnings({ "rawtypes", "unchecked" })
            @Override
            public IModel getDataModel(final IModel<T> rowModel){....}

and everything works, but I don't like this solution. This is (in my book) not clean code. 

I would like to know, is there anybody that have a better solution, and if not, is it possible to change the return value of getDataModel to IModel<?> ?

Yours
Tron
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


SV: Deprecation of createLabelModel

Posted by Tron Walseth <tr...@telespor.no>.
Hi 

My problem is that in most cases, the propertycolumn is an anonymous class. 

I will think about this, and see if it's not possible to make this a named class. Maybe this will be the solution....

Yours,
Tron
________________________________________
Fra: Jesse Long [jpl@unknown.za.net]
Sendt: 13. mars 2013 10:57
Til: users@wicket.apache.org
Emne: Re: Deprecation of createLabelModel

Hi Tron,

Would it not suffice to change PropertyColumn to implement
IExportableColumn<T, S, ? extends Object>? This would make the return
type of getDataModel() a IModel<? extends Object>, and IModel<String>
will work.

Alternative is in Wicket 7, remove third type parameter for
IExportableColumn, and make getDataModel() return IModel<?>. Downside of
this is that you can never getDataModel().setObject(), but I dont think
anyone does that anyways.

Cheers,
Jesse

On 13/03/2013 11:39, Tron Walseth wrote:
> Hi
>
> A bit of advice is needed;
>
> The method createDataLabel of org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn is deprecated since 6.2.0, and the documentation advice is to use public IModel<Object> getDataModel(IModel<T> rowModel) instead.
>
> We have overridden this method in some places, and in most cases, the method returns a ResourceModel (IModel<String>). When fixing deprecation warnings by changing the method name, the compiler complains that the return type is not correct.
>
> The solution is fairly simple, just change the signature to
>              @SuppressWarnings({ "rawtypes", "unchecked" })
>              @Override
>              public IModel getDataModel(final IModel<T> rowModel){....}
>
> and everything works, but I don't like this solution. This is (in my book) not clean code.
>
> I would like to know, is there anybody that have a better solution, and if not, is it possible to change the return value of getDataModel to IModel<?> ?
>
> Yours
> Tron
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


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


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


Re: Deprecation of createLabelModel

Posted by Jesse Long <jp...@unknown.za.net>.
Hi Tron,

Would it not suffice to change PropertyColumn to implement 
IExportableColumn<T, S, ? extends Object>? This would make the return 
type of getDataModel() a IModel<? extends Object>, and IModel<String> 
will work.

Alternative is in Wicket 7, remove third type parameter for 
IExportableColumn, and make getDataModel() return IModel<?>. Downside of 
this is that you can never getDataModel().setObject(), but I dont think 
anyone does that anyways.

Cheers,
Jesse

On 13/03/2013 11:39, Tron Walseth wrote:
> Hi
>
> A bit of advice is needed;
>
> The method createDataLabel of org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn is deprecated since 6.2.0, and the documentation advice is to use public IModel<Object> getDataModel(IModel<T> rowModel) instead.
>
> We have overridden this method in some places, and in most cases, the method returns a ResourceModel (IModel<String>). When fixing deprecation warnings by changing the method name, the compiler complains that the return type is not correct.
>
> The solution is fairly simple, just change the signature to
>              @SuppressWarnings({ "rawtypes", "unchecked" })
>              @Override
>              public IModel getDataModel(final IModel<T> rowModel){....}
>
> and everything works, but I don't like this solution. This is (in my book) not clean code.
>
> I would like to know, is there anybody that have a better solution, and if not, is it possible to change the return value of getDataModel to IModel<?> ?
>
> Yours
> Tron
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


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