Tapestry
  1. Tapestry
  2. TAPESTRY-2310

LabeledPropertySelectionModel.isDisabled always disables its first option

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.1.5
    • Fix Version/s: 4.1.6
    • Component/s: Core Components
    • Labels:
      None

      Description

      Maybe I understand LabeledPropertySelectionModel incorrectly,
      but in 4.1.3 I could choose the "default" option, and since 4.1.5 I cannot anymore.
      The model I use is like this:

      public static final IPropertySelectionModel MY_MODEL = new LabeledPropertySelectionModel(
      new StringPropertySelectionModel(new String[]

      { "first", "second", "third" }

      ));

      The reason is change in revision 592802:
      http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/LabeledPropertySelectionModel.java?r1=515387&r2=592802&diff_format=h

      It makes option #0 ALWAYS disabled.
      This just isn't fare

      I propose to make it configurable:

      public class LabeledPropertySelectionModel implements IPropertySelectionModel
      {
      ...
      private boolean _disableDefaultLabel;
      ...
      public LabeledPropertySelectionModel(IPropertySelectionModel model, String label, Object option, String value, boolean disableDefaulLabel)

      { this(model, label, option, value); _disableDefaultLabel = disableDefaulLabel; }

      ...
      public boolean isDisabled(int index)

      { return index == 0 ? _disableDefaultLabel : _model.isDisabled(index - 1); }

      ...

        Activity

        Hide
        Andreas Andreou added a comment -

        What it does is that it adds a new option (by default an empty string) at the top
        and makes it disabled so that users cannot select it (since it's not really part of
        your model).

        So, the idea that this 'label' is disabled seems correct...

        However, i've seen a browser (think it's Opera) that doesn't select the disabled
        label option when the page loads (don't know what the specs say on this),
        which defeats the purpose of this.
        Perhaps that's why gmail doesn't lately display the combobox when it's closed.

        Anyway, I believe it wouldn't hurt to add what you're suggesting.

        Show
        Andreas Andreou added a comment - What it does is that it adds a new option (by default an empty string) at the top and makes it disabled so that users cannot select it (since it's not really part of your model). So, the idea that this 'label' is disabled seems correct... However, i've seen a browser (think it's Opera) that doesn't select the disabled label option when the page loads (don't know what the specs say on this), which defeats the purpose of this. Perhaps that's why gmail doesn't lately display the combobox when it's closed. Anyway, I believe it wouldn't hurt to add what you're suggesting.

          People

          • Assignee:
            Andreas Andreou
            Reporter:
            Albert Tumanov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development