Wicket
  1. Wicket
  2. WICKET-3929

PropertyModel/PropertyResolver breaks when using a List as the root object

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.17, 1.5-RC5.1
    • Fix Version/s: 1.4.19, 1.5-RC6
    • Component/s: wicket
    • Labels:
      None

      Description

      When using a java.util.List as the root target of a PropertyModel, and then using a property expression such as "[0].someProperty", PropertyResolver breaks rather badly, claiming that "0].somePropert" is not a valid property expression. Note the missing first and last characters.

      This happens because it first replaces all opening "[" with ".[", and thus we get a leading "." in the expression. That "." is then cut off, but the rest of the expression is suddenly treated as a single property name. A later step sees the leading "[" and thinks the whole thing is just a map/list index, and so drops the leading "[" and the last character (in the mistaken belief that the last character must be a "]".

      To make a long story short: The whole thing is fixed by eating the leading dots before entering the main resolver loop. I'm attaching patches for 1.4.x and trunk(1.5).

        Activity

        Hide
        Martin Grigorov added a comment -

        The patches are applied.
        Thanks!

        Show
        Martin Grigorov added a comment - The patches are applied. Thanks!
        Hide
        Carl-Eric Menzel added a comment -

        Ah, I see. Well, it would be more obvious with my patch

        I ran into this while working on my SafeModel implementation. I'd really like the more consistent syntax, because then I could have it work with lists without doing a special case for the first step. Thanks!

        Show
        Carl-Eric Menzel added a comment - Ah, I see. Well, it would be more obvious with my patch I ran into this while working on my SafeModel implementation. I'd really like the more consistent syntax, because then I could have it work with lists without doing a special case for the first step. Thanks!
        Hide
        Pedro Santos added a comment -

        Hi Carl, in the PropertyResolver javadoc the property[index] or property[key] syntax is designed for properties. I'm attaching the test case working by removing some '[' and ']' s

        Anyway I'm 1+ for the patch because it makes the resolver syntax more consistent by no differentiating the [index] in beginning of the expression from those in the middle.

        Show
        Pedro Santos added a comment - Hi Carl, in the PropertyResolver javadoc the property [index] or property [key] syntax is designed for properties. I'm attaching the test case working by removing some ' [' and '] ' s Anyway I'm 1+ for the patch because it makes the resolver syntax more consistent by no differentiating the [index] in beginning of the expression from those in the middle.
        Hide
        Carl-Eric Menzel added a comment -

        These patches contain test cases for the described behavior, and a fix for PropertyResolver, for 1.4.x and trunk(1.5).

        Show
        Carl-Eric Menzel added a comment - These patches contain test cases for the described behavior, and a fix for PropertyResolver, for 1.4.x and trunk(1.5).

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Carl-Eric Menzel
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development