Tapestry
  1. Tapestry
  2. TAPESTRY-1193

.script files: "index" property of "foreach" tag is stored as a String, not an integer

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.0.2
    • Fix Version/s: 4.1.2
    • Component/s: Framework
    • Labels:
      None

      Description

      In .script files, the "index" value of the "foreach" tag is stored as a String, not an integer.

      If you have a two-dimensional array stored in the input-symbol "matrix", the following will work fine:
      $

      {matrix[0].length}

      But the following, where "matrixIndex" is the symbol used for a surrounding "foreach"-tag's "index" value, will throw an error:
      $

      {matrix[matrixIndex].length}

      The error will tell you that "matrix" does not have the property: 0.
      i.e. since matrixIndex is a String, it's looking for a property of the array-object named "0".

      This issue doesn't arise with comparisons, such as $

      {matrixIndex > 0}

      , because OGNL knows to interpret matrixIndex as an integer. However, again, in the case of indexes to [ ], both an integer and String parameter are acceptable, so no implicit casting is done on the String.

      A workaround: $

      {matrix[@java.lang.Integer@parseInt(matrixIndex)].length}

        Activity

        Hide
        Jesse Kuhnert added a comment -

        Think its been fixed now, if not please open an issue in http://jira.opensymphony.com/browse/OGNL .

        Show
        Jesse Kuhnert added a comment - Think its been fixed now, if not please open an issue in http://jira.opensymphony.com/browse/OGNL .

          People

          • Assignee:
            Jesse Kuhnert
            Reporter:
            Jim Steinberger
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development