|
|
|
You'll have to use the 2.7.1-SNAPSHOT version to get the fix.
Thank you for that fix, it is most appreciated. However, I have come across another part of my app that triggers this bug. In Tapestry I have a For loop component iterating over a list declared as:
public List<DataObject> getSearchResultsList() {...} and we have an iterator property as: public abstract DataObject getSearchResultIter(); In this list of results, we can have both MpPublication objects and Publication objects, each of which are subclasses of DataObject. Both of these classes declare a property "title", however this is not declared in any common interface or superclass. Inside the loop, I have an Insert component that renders the title as follows: <span jwcid="@Insert" value="ognl:searchResultIter.title" /> Prior to ognl 2.7 this worked, now I get the following exception: Caused by: java.lang.ClassCastException: com.jigsawpublications.db.app.MpPublication at $ASTChain_113dc4844df.get($ASTChain_113dc4844df.java) at org.apache.tapestry.services.impl.ExpressionEvaluatorImpl.read(ExpressionEvaluatorImpl.java:142) Which is the same as what I was getting with the previous comment. I am using OGNL 2.7.1-20070717.203010-7.jar from http://opencomponentry.com/repository/m2-snapshot-repo/ognl/ognl/2.7.1-SNAPSHOT/. Note that the bug from my previous comment is fixed in this version. If you require more information, please let me know. Unfortunately - if there is no shared interface method that is common between the classes there is no fix for this.
I would suggest adding the title attribute to some sort of interface. Ah yes, I was relying on OGNL's (formerly) weakly typed nature due to it discovering methods via reflection, now that is not the case. In my case the fix is easy:
<span jwcid="@Insert" value="ognl:searchResultIterTitle" /> public String getSearchResultIterTitle() { return (String) getSearchResultIter().readProperty("title"); } This new behaviour would certainly be a useful bit of information in some kind of "Migrating from OGNL 2.6 and earlier to 2.7" type document :-) Thank you for your prompt response. | ||||||||||||||||||||||||||||||||||||||||||||||
having this same class cast exception on an ASTChain generated class,
stack trace is here:
Caused by: java.lang.ClassCastException:
com.jigsawpublications.common.tapestry.menu.ActionLinkNode
at $ASTChain_113aed5c33f.get($ASTChain_113aed5c33f.java)
at
org.apache.tapestry.services.impl.ExpressionEvaluatorImpl.read(ExpressionEvaluatorImpl.java:142)
What we have in the component template looks like this:
<span jwcid="actionLink@Block">
<li>
<a jwcid="@DirectLink" listener="listener:callParentAction"
parameters="ognl:getNodeIter().getAction()"
href="#" title="ognl:nodeIter.title">
<span jwcid="@Insert" value="ognl:nodeIter.title" />
</a>
</li>
</span>
The nodeIter property on the component class is declared as follows:
public IMenuNode getNodeIter() { ....}
So what we have here is a list of objects all implementing this
interface IMenuNode, and getNodeIter() returns the current iteration as
set by the tapestry @For component. The class cast exception was on an
ActionLinkNode which implements that interface. Other classes are
PageLinkNode, RootNode and MenuNode. The *only* one that causes a
problem seems to be the above @Block component, as another block:
<span jwcid="pageLink@Block">
<li>
<a jwcid="@PageLink" href="#" title="ognl:nodeIter.title"
page="ognl:nodeIter.page">
<span jwcid="@Insert" value="ognl:nodeIter.title" />
</a>
</li>
</span>
renders fine without any issue (these other blocks occur earlier in the
page than the ActionLinkBlock). If I change the actionLink block to be
the following (i.e. change the offending ognl expressions):
<span jwcid="actionLink@Block">
<li>
<a jwcid="@DirectLink" listener="listener:callParentAction"
parameters="ognl:'action'"
href="#" title="ognl:'title'">
<span jwcid="@Insert" value="ognl:'title'" />
</a>
</li>
</span>
Then I do not get an exception during the page render. This worked fine
with the previous version of ognl we were using (2.6.7).
Please let me know if you require more information.
(Sorry for the Cloned bug, I'm new to JIRA, I just wanted to reopen the bug like you can in bugzilla).