« Return to Thread: users, please give us your opinion: what is your take on generics with Wicket

Re: Making Component easier to Generify

by cowwoc :: Rate this Message:

Reply to Author | View in Thread


You could reduce the verbosity by combining all your dynamic content (anything you would normally add when subclassing a component) into a separate class. For example:

class Images
{
  Callable<Boolean> isVisible()
  {
    ...
  }
  Callable<Integer> getItemsPerPage()
  {
    ...
   }
}

main()
{
  DataView<Image> images = DataView.create(); // factory method
  Images imageState = new Images();
  images.setItemsPerPage(imageState.getItemsPerPage());
  images.setVisible(imageState.isVisible());
  ...
}

Gili


Matej Knopp-2 wrote:
Apart from the fact that this would be even more verbose than current
generics approach this would probably also radically increase
component memory footprint.

-Matej

On Thu, Jun 12, 2008 at 7:03 AM, cowwoc <cowwoc@bbs.darktech.org> wrote:
>
>
> Have you considered moving from subclassing to composition in Wicket using
> Callable<T>?
>
> Currently it is quite common for developers to subclass a component in order
> to override isVisible() and other properties. I am proposing that instead
> the component classes become final and properties may only be set using
> setter methods. The setter methods would take Callable<T> instead of T, so
> for example setVisible(boolean) would become setVisible(Callable<Boolean>)
>
> The benefit of this approach is that you could introduce static factory
> methods to the Wicket components which would make them much easier to use in
> their Generic form. You could then introduce various helper classes to
> create Callable<T> for constant values, such as Callable.valueOf(true) would
> return a Callable<Boolean> that always returns true.
> --
> View this message in context: http://www.nabble.com/users%2C-please-give-us-your-opinion%3A-what-is-your-take-on-generics-with-Wicket-tp17589984p17792488.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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

 « Return to Thread: users, please give us your opinion: what is your take on generics with Wicket