Uploaded image for project: 'Commons OGNL (Dormant)'
  1. Commons OGNL (Dormant)
  2. OGNL-24

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.7
    • 4.0
    • ExpressionCompiler
    • None
    • 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.

      Attachments

        Activity

          People

            jkuhnert Jesse Kuhnert
            dotteben Ben Dotte
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: