Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2930

Method isSelected in Select should be public

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.9
    • Fix Version/s: 1.5.1
    • Component/s: wicket-extensions
    • Labels:
      None

      Description

      Please change the scope of the method isSelected in the class org.apache.wicket.extensions.markup.html.form.select.Select to public so that it can be called from elsewhere or even overridden in subclasses elsewhere.

      Background: In our current project we came to the conclusion that the Choice classes of the Wicket core are not suitable to implement panels with radio buttons, where the radio buttons need to be rendered from an EnumSet or from Collection. We particularly needed to be able to define the markup of each option in a template. Moreover we needed to be able to define the CSS classes on the option tag itself. Another requirement was Ajax support, in which the selection of a radio button is immediately submitted to the server. We had a look at the class org.apache.wicket.extensions.markup.html.form.select.Select which we knew was doing a good job for drop-down boxes in the way we needed it. We made the decision to create additional classes around it to support radio buttons. Our approach worked, but we had to use Java Reflection because the crucial method isSelected in the Select class is package local. Will there be changes in the Wicket core or in wicket-extensions to improve the support for radio buttons? I heard that in 1.5 there may be improvements.

      1. fix-WICKET-2930.patch
        0.6 kB
        Tomasz Dziurko

        Activity

        Hide
        ivaynberg Igor Vaynberg added a comment -

        for radio buttons there is RadioGroup and Radio components...why dont those work for what you want?

        Show
        ivaynberg Igor Vaynberg added a comment - for radio buttons there is RadioGroup and Radio components...why dont those work for what you want?
        Hide
        sludwig Sven Ludwig added a comment -

        We have implemented isSelected ourselves to make the Select work with our own SelectOptions Subclass for radio buttons and check-boxes. Out of the box the Select only works for drop-downs. Our motivation to use the Select for radio-buttons/check-boxes was to be able to define the mark-up for the radio-buttons/check-boxes in an html-template, which is not possible using the Wicket 1.4 RadioChoice.

        Show
        sludwig Sven Ludwig added a comment - We have implemented isSelected ourselves to make the Select work with our own SelectOptions Subclass for radio buttons and check-boxes. Out of the box the Select only works for drop-downs. Our motivation to use the Select for radio-buttons/check-boxes was to be able to define the mark-up for the radio-buttons/check-boxes in an html-template, which is not possible using the Wicket 1.4 RadioChoice.
        Hide
        ivaynberg Igor Vaynberg added a comment -

        i dont understand why you would want to call this method from outside or be able to override it...

        Show
        ivaynberg Igor Vaynberg added a comment - i dont understand why you would want to call this method from outside or be able to override it...
        Hide
        tdziurko Tomasz Dziurko added a comment -

        I am attaching fix for this issue.

        Show
        tdziurko Tomasz Dziurko added a comment - I am attaching fix for this issue.
        Hide
        jdonnerstag Juergen Donnerstag added a comment -

        would it be able for you to contribute your code to the Wicket project? We are always interested to learn from Wicket users and consider for improvements what they've learnt. Thanks for considering.

        Show
        jdonnerstag Juergen Donnerstag added a comment - would it be able for you to contribute your code to the Wicket project? We are always interested to learn from Wicket users and consider for improvements what they've learnt. Thanks for considering.
        Hide
        martin-g Martin Grigorov (Inactive) added a comment -

        Cite: "We made the decision to create additional classes around it to support radio buttons."

        Workaround: Instead of using reflections you can create a new class (an adapter) with the same package but different class name and this class will extend Wicket's Select just to expose #isSelected(SelectOption) as public. Then your "additional class" (MySelect) will extend the adapter.

        Show
        martin-g Martin Grigorov (Inactive) added a comment - Cite: "We made the decision to create additional classes around it to support radio buttons." Workaround: Instead of using reflections you can create a new class (an adapter) with the same package but different class name and this class will extend Wicket's Select just to expose #isSelected(SelectOption) as public. Then your "additional class" (MySelect) will extend the adapter.

          People

          • Assignee:
            Unassigned
            Reporter:
            sludwig Sven Ludwig
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 0.5h
              0.5h
              Remaining:
              Remaining Estimate - 0.5h
              0.5h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development