Commons OGNL
  1. Commons OGNL
  2. OGNL-24

Property cast as java.util.List instead of intended interface

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.7
    • Fix Version/s: 4.0
    • Component/s: ExpressionCompiler
    • Labels:
      None
    • Environment:
      Tapestry 4.1.2 snapshot from 3-21, OGNL 2.7 snapshot from 3-25, Firefox 2, WinXP

      Description

      This template snippet evaluates properly in OGNL 2.6:

      <showAll jwcid="@ShowAll"

      count="ognl:components.doxList.model.listSource.total" title=""

      pageName="MyDocuments" >

      <div class="shadeIconIndent">

      <br/>

      <myDocs jwcid="doxList@MyDocumentsList"

      allowItemsPerPageSelection="false"/>

      </div>

      </showAll>

      The count expression "ognl:components.doxList.model.listSource.total" is the problem in 2.7. This error appears in the stack trace:

      Unable to parse OGNL expression

      'components.doxList.model.listSource.total': Error compiling expression on object $BuilderAccount_106@3c1[BuilderAccount] with expression node components.doxList.model.listSource.total getter body:

      { return ($w) (((java.util.List)((collective.listcontainer.model.BaseListContainerMode l)((collective.mb.ui.components.MyDocumentsList)(($BuilderAccount_106)$2 ).getComponents().get("doxList")).getModel()).getListSource()).get(total ));}

      setter body: null

      getListSource().get(total) should be getListSource().getTotal(). The concrete implementation of listSource both extends ArrayList and implements the ListSource interface, which has a getTotal() method that returns an int (the intended method). Presumably since it also extends ArrayList, getListSource() is being cast to java.util.List, at which point the get() method is being called.

      I think OGNL 2.6's interpretation of getListSource().getTotal() makes more sense here than calling the get() method on java.util.List.

        Activity

        Hide
        Jesse Kuhnert added a comment -

        Updated accessor to check for methods.

        Show
        Jesse Kuhnert added a comment - Updated accessor to check for methods.

          People

          • Assignee:
            Jesse Kuhnert
            Reporter:
            Ben Dotte
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development