History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: OGNL-130
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Jesse Kuhnert
Reporter: Dom Couldwell
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OGNL

Array syntax error

Created: 19/Oct/07 04:30 PM   Updated: 23/Oct/07 08:43 AM
Component/s: None
Affects Version/s: 2.7
Fix Version/s: 2.7.2

Environment: Tapestry 4.1.2, Java 1.5


 Description  « Hide
I'm migrating an existing project which uses 4.0.2 to use 4.1.2 and I'm having and ognl / loop related issue.

Here's the snippet that works on 4.0.2

      <td jwcid="@For"
          source="ognl:tab.searchCriteriaOptions"
          value="ognl:currentFilterGroup"
          index="ognl:currentFilterGroupIndex">
        <div jwcid="@If"
             element="literal:td"
             condition="ognl:tab.searchCriteria[currentFilterGroupIndex] != null"
             class="ognl:'filter' + getFilterColumnStyle(currentFilterGroupIndex)">
        <select jwcid="@Select"
                multiple="literal:false"
                size="10"
                onchange="ognl:'searchSubmit(\''+@com.db.rdq.web.tapestry.html.component.Search@FILTER+'\', '+currentFilterGroupIndex+');'">
          <div jwcid="@For"
               source="ognl:currentFilterGroup"
               value="ognl:currentFilter"
               index="ognl:currentFilterIndex">
          <option jwcid="@Option"
                  selected="ognl:tab.searchCriteriaSelections[currentFilterGroupIndex][currentFilterIndex]"
                  label="ognl:currentFilter">
          </option>
          </div>
        </select>
        </div>
      </td>

But under 4.1.2 it's giving me the error:

2007-10-19 16:31:13,878, ERROR, [org.apache.tapestry.services.impl.HiveMindExpressionCompiler], line 179, Error generating OGNL getter for expression tab.searchCriteriaSelections[currentFilterGroupIndex][currentFilterIndex] with root $Search_91@dc4a91e5[Home/$Search] and body:
{ return ($w) (((java.util.List)(($Search_91)$2).getTab().getSearchCriteriaSelections()).get((($Search_91)$2).getCurrentFilterGroupIndex())).get(((java.util.List)(($Search_91)$2).getCurrentFilterIndex()));}
org.apache.hivemind.ApplicationRuntimeException: Unable to add method java.lang.Object get(ognl.OgnlContext, java.lang.Object) to class $ASTChain_115b9f4b263: [source error] get(java.util.List) not found in java.lang.Object
at org.apache.tapestry.enhance.ClassFabImpl.addMethod(ClassFabImpl.java:278)
...
Caused by: javassist.CannotCompileException: [source error] get(java.util.List) not found in java.lang.Object
at javassist.CtBehavior.setBody(CtBehavior.java:347)
at javassist.CtBehavior.setBody(CtBehavior.java:316)
at org.apache.tapestry.enhance.ClassFabImpl.addMethod(ClassFabImpl.java:272)
... 161 more
Caused by: compile error: get(java.util.List) not found in java.lang.Object
...

Should we be using different ognl syntax for the new version of Tapestry?

I've tried updating the problem line to
selected="ognl:getTab().getSearchCriteriaSelections().get(currentFilterGroupIndex).get(currentFilterIndex)"

which works when the page serves but does not write the values back to the page:

2007-10-19 17:01:08,272, ERROR, [com.db.rdq.web.tapestry.html.RDQException], line 22, org.apache.tapestry.BindingException
2007-10-19 17:01:08,272, ERROR, [com.db.rdq.web.tapestry.html.RDQException], line 23, Unable to update OGNL expression '<parsed OGNL expression>' of $Search_161@dc4a91e5[Home/$Search] to true: Inappropriate OGNL expression: get(currentFilterIndex)
2007-10-19 17:01:08,272, ERROR, [com.db.rdq.web.tapestry.html.RDQException], line 32,
2007-10-19 17:01:08,272, ERROR, [com.db.rdq.web.tapestry.html.RDQException], line 44,
binding|ExpressionBinding[Home/$Search getTab().getSearchCriteriaSelections().get(currentFilterGroupIndex).get(currentFilterIndex)]
location|context:/WEB-INF/Search.html, line 106
2007-10-19 17:01:08,272, ERROR, [com.db.rdq.web.tapestry.html.RDQException], line 22, org.apache.hivemind.ApplicationRuntimeException
2007-10-19 17:01:08,287, ERROR, [com.db.rdq.web.tapestry.html.RDQException], line 23, Unable to update OGNL expression '<parsed OGNL expression>' of $Search_161@dc4a91e5[Home/$Search] to true: Inappropriate OGNL expression: get(currentFilterIndex)
2007-10-19 17:01:08,287, ERROR, [com.db.rdq.web.tapestry.html.RDQException], line 32,
2007-10-19 17:01:08,287, ERROR, [com.db.rdq.web.tapestry.html.RDQException], line 44,
component|$Search_161@dc4a91e5[Home/$Search]
location|context:/WEB-INF/Home.html, line 51
2007-10-19 17:01:08,287, ERROR, [com.db.rdq.web.tapestry.html.RDQException], line 22, ognl.InappropriateExpressionException

 All   Comments   Change History      Sort Order:
Dom Couldwell - [22/Oct/07 07:20 AM ]
Tapestry version should be 4.1.3 not 4.1.2

Dom Couldwell - [22/Oct/07 08:42 AM ]
Pertinent parts of Java and Config

Search.java

    public abstract SearchTab getTab();
    
    public abstract int getCurrentSearchItemIndex();
    public abstract int getCurrentFilterGroupIndex();
    public abstract int getCurrentFilterIndex();

Search.jwc

    <property name="currentSearchItem"/>
    <property name="currentFilterGroup"/>
    <property name="currentFilter"/>

SearchTab.java

    public List<List<String>> getSearchCriteriaOptions() {
        return this.searchCriteriaOptions;
    }
    public void setSearchCriteriaOptions(
            List<List<String>> searchCriteriaOptions) {
        this.searchCriteriaOptions = searchCriteriaOptions;
    }

    public List<List<Boolean>> getSearchCriteriaSelections(){
        return this.searchCriteriaSelections;
    }
    public void setSearchCriteriaSelections(List<List<Boolean>> selections){
        this.searchCriteriaSelections = selections;
    }