Wicket
  1. Wicket
  2. WICKET-3652

Provide a Typesafe Panel, that allows to use getDefaultModel and getDefaultModelObject without casting

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5-RC3
    • Fix Version/s: 1.5-RC5
    • Component/s: wicket
    • Labels:
      None

      Description

      I want to use panels in a generic way with no need to cast, if I use getDefaultModel and getDefaultModelObject.

      This issue has been thoroughly discussed, and thats why Panel is currently not implemented using generics.
      Please provide a class TypedPanel instead, that can be used interchangeably with Panel itself.

      The Implementation could provide the following Methods:

      public T getDefaultModel()
      public T getDefaultModelObject()

      That would make usage of typed panels much more cleaner.

        Activity

        Hide
        Martin Dilger added a comment -

        a simple patch, that provides the idea as implementation.

        Show
        Martin Dilger added a comment - a simple patch, that provides the idea as implementation.
        Hide
        Martin Grigorov added a comment -

        I like the idea. Additionally I think to add TypedPage which will extend from WebPage.
        Pages and Panels are the most often created custom components.

        Show
        Martin Grigorov added a comment - I like the idea. Additionally I think to add TypedPage which will extend from WebPage. Pages and Panels are the most often created custom components.
        Hide
        Igor Vaynberg added a comment -

        methods should be called getsetmodel()/getsetmodelobject() just like they are in everything else that is generified.

        Show
        Igor Vaynberg added a comment - methods should be called getsetmodel()/getsetmodelobject() just like they are in everything else that is generified.
        Hide
        Martin Dilger added a comment -

        Of course you are absolutely right.
        I provided a new patch that also contains the idea of TypedPage.

        Show
        Martin Dilger added a comment - Of course you are absolutely right. I provided a new patch that also contains the idea of TypedPage.
        Hide
        Martin Grigorov added a comment -

        GenericWebPage and GenericPanel are added with r1129038.

        Show
        Martin Grigorov added a comment - GenericWebPage and GenericPanel are added with r1129038.
        Hide
        Ivan Vasilev added a comment - - edited

        Hello,
        Inside GenericPanel and GenericWebPage:

        @SuppressWarnings("unchecked")
        public final T getModel()

        { return (T)getDefaultModel(); }

        Shouldn't it be:

        @SuppressWarnings("unchecked")
        public final T getModel()

        { return (IModel<T>)getDefaultModel(); }

        Also, do you think similar GenericFragment should can be added? Thanks.

        Show
        Ivan Vasilev added a comment - - edited Hello, Inside GenericPanel and GenericWebPage: @SuppressWarnings("unchecked") public final T getModel() { return (T)getDefaultModel(); } Shouldn't it be: @SuppressWarnings("unchecked") public final T getModel() { return (IModel<T>)getDefaultModel(); } Also, do you think similar GenericFragment should can be added? Thanks.
        Hide
        Martin Grigorov added a comment -

        Yep, this is a bug. Thanks!
        About GenericFragment - not sure, then someone will want GenericWebMarkupContainer, ... At the end we can make Component<T> and solve them all. But this has been discussed already.

        Show
        Martin Grigorov added a comment - Yep, this is a bug. Thanks! About GenericFragment - not sure, then someone will want GenericWebMarkupContainer, ... At the end we can make Component<T> and solve them all. But this has been discussed already.

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Martin Dilger
          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development