Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.4
    • Fix Version/s: 1.6
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      Operating System: other
      Platform: Other

      Description

      I know velocity can only introspect Methods, not member variables, but
      perhaps you could make an exception for arrays?
      Arrays are basically suported with foreach iteration.
      Now it would be great if I could also say "$myarray.length items displayed".
      Is this possible somehow now?
      If not, does someone agree this could be implemented?

      I think .length support should be possible only IF the passed variable is an
      array, and for nothing else.

        Issue Links

          Activity

          Hide
          Geir Magnusson Jr added a comment -

          And what should happen when the variable is not an array?

          Show
          Geir Magnusson Jr added a comment - And what should happen when the variable is not an array?
          Hide
          Gernot Hüller added a comment -

          The user's guide, "Quiet Reference Notation" says
          "When Velocity encounters an undefined reference, its normal behavior is to
          output the image of the reference."

          This is also done if you access a method that does not exist,
          e.g. "$myvar.toStringg()" (typo intended)

          So I guess that's also a fine behavior if the variable is not an array and you
          want to use .length on it.

          Show
          Gernot Hüller added a comment - The user's guide, "Quiet Reference Notation" says "When Velocity encounters an undefined reference, its normal behavior is to output the image of the reference." This is also done if you access a method that does not exist, e.g. "$myvar.toStringg()" (typo intended) So I guess that's also a fine behavior if the variable is not an array and you want to use .length on it.
          Hide
          Shinobu Kawai added a comment -

          As for now, you can use

          Show
          Shinobu Kawai added a comment - As for now, you can use PublicFieldUberspect to directly expose "length" http://wiki.apache.org/jakarta-velocity/PublicFieldUberspect ArrayTool to get "length" from arrays http://wiki.apache.org/jakarta-velocity/ArrayTool
          Hide
          Will Glass-Husain added a comment -

          This keeps coming up on the user list. I think it makes sense. Someone needs to write the patch, of course.

          Show
          Will Glass-Husain added a comment - This keeps coming up on the user list. I think it makes sense. Someone needs to write the patch, of course.
          Hide
          Nathan Bubna added a comment -

          I think given the workarounds offered by the ListTool in Velocity Tools (in svn head) and the PublicFieldUberspect on the wiki, this should be pretty well covered until Issue VELOCITY-365 is implemented, at which point this would be counter-productive.

          so i'd vote to have this closed as "won't fix" or as a duplicate of VELOCITY-365.

          Show
          Nathan Bubna added a comment - I think given the workarounds offered by the ListTool in Velocity Tools (in svn head) and the PublicFieldUberspect on the wiki, this should be pretty well covered until Issue VELOCITY-365 is implemented, at which point this would be counter-productive. so i'd vote to have this closed as "won't fix" or as a duplicate of VELOCITY-365 .
          Hide
          Will Glass-Husain added a comment -

          I agree.

          Show
          Will Glass-Husain added a comment - I agree.
          Hide
          Will Glass-Husain added a comment -

          Eventually, we'll do all List operations on arrays as noted in Velocity-365

          Show
          Will Glass-Husain added a comment - Eventually, we'll do all List operations on arrays as noted in Velocity-365

            People

            • Assignee:
              Unassigned
              Reporter:
              Gernot Hüller
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development