This content has been marked as final.
Show 5 replies
-
1. Re: s:selectItems and subclasses
pmuir Nov 12, 2007 12:04 PM (in response to mschmidke)What version of Seam. Lets see the exception stack trace.
-
2. Re: s:selectItems and subclasses
mschmidke Nov 13, 2007 7:17 AM (in response to mschmidke)Seam Version is 2.0.0.CR1.
JSF RI from JBoss 4.2.
No stack trace available since the exception is silently caught.
Have a look at JSF RI MenuRenderer.java lines 535 ff:try { newValue = context.getApplication().getExpressionFactory(). coerceToType(itemValue, type); } catch (Exception e) { // this should catch an ELException, but there is a bug // in ExpressionFactory.coerceToType() in GF newValue = null; }
So, I think it is not a bug of Seam, but it is a limitation of JSF which appears when using Seam UI components (it might appear without Seam, but it will appear with Seam), and since Seam is nothing but repairing things which are missing in the other frameworks, it would be nice if Seam could repair even this.
I have worked around this by replacing the MenuRenderer class, changing getCurrentSelectedValues() method: Instead ofif (size > 0) { // get the type of the first element - Should // we assume that all elements of the List are // the same type? return list.toArray((Object[]) Array.newInstance( list.iterator().next().getClass(), size)); } else { return ((Collection) value).toArray(); }
I haveif (size > 0) { // get the type of the first element - Should // we assume that all elements of the List are // the same type? return list.toArray((Object[]) Array.newInstance( getObjectClass(list.iterator().next()), size)); } else { return ((Collection) value).toArray(); }
withprivate Class getObjectClass(Object o) { Class r = o.getClass(); if (r.getName().contains("$$")) { r = r.getSuperclass(); } return r; }
This method changes the class from "Proxy-For-A" to "A", so that even Bs and Cs may match.
This is clearly a hack, but for the moment, it works for me. -
3. Re: s:selectItems and subclasses
pmuir Nov 15, 2007 9:53 AM (in response to mschmidke)Please open a JIRA issue. I shall use it to track a discussion with the JSF RI team to see if we can improve this.
-
4. Re: s:selectItems and subclasses
mschmidke Nov 16, 2007 2:09 AM (in response to mschmidke)"pete.muir@jboss.org" wrote:
Please open a JIRA issue.
Perhaps this is a little off topic, but I do not seem to have the permission to create new issues on jira.jboss.org. What can I do?
Marcus. -
5. Re: s:selectItems and subclasses
pmuir Nov 16, 2007 4:37 AM (in response to mschmidke)log into jira using the same account you use to log in to jboss.com for the forums