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

          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          663d 8h 52m 1 Will Glass-Husain 20/Sep/05 04:19
          Mark Thomas made changes -
          Workflow Default workflow, editable Closed status [ 12551326 ] jira [ 12552041 ]
          Mark Thomas made changes -
          Workflow jira [ 12325107 ] Default workflow, editable Closed status [ 12551326 ]
          Will Glass-Husain made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Won't Fix [ 2 ]
          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
          Will Glass-Husain made changes -
          Link This issue duplicates VELOCITY-365 [ VELOCITY-365 ]
          Hide
          Will Glass-Husain added a comment -

          I agree.

          Show
          Will Glass-Husain added a comment - I agree.
          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 .
          Will Glass-Husain made changes -
          Fix Version/s 1.6 [ 12310290 ]
          Bugzilla Id 25007
          Assignee Velocity-Dev List [ velocity-dev@jakarta.apache.org ]
          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.
          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.
          Environment Operating System: other
          Platform: Other
          Operating System: other
          Platform: Other
          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.
          Jeff Turner made changes -
          Field Original Value New Value
          issue.field.bugzillaimportkey 25007 12315102
          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
          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
          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?
          Gernot Hüller created issue -

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development