rich:dropDownMenu: Enum in renderer vs. String in Component API - EL coercion problem
-------------------------------------------------------------------------------------
Key: RF-10192
URL:
https://issues.jboss.org/browse/RF-10192
Project: RichFaces
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: component-menu
Affects Versions: 4.0.0.Milestone5
Environment: RichFaces 4 M5
Reporter: Martin Kočí
<r:dropDownMenu mode="#{beanNull.mode}" >
java.lang.IllegalArgumentException: No enum const class org.richfaces.component.Mode.
at java.lang.Enum.valueOf(Enum.java:196)
at org.richfaces.component.Mode.valueOf(Mode.java:24)
at
org.richfaces.renderkit.html.MenuItemRendererBase.resolveSubmitMode(MenuItemRendererBase.java:120)
Reason:
MenuItemRendererBase calls Mode.valueOf(abstractDropDownMenu.getMode()); but
AbstractDropDownMenu.getMode() returns String - then if #{} resolves to null, EL will
coerce null to "" ([1]) and returns it from getMode() method.
Solutions:
1) use quick fix like:
String mode = parent.getMode();
if (StringUtils.isEmpty(mode)) {
return Mode.server;
}
2) Disable this (stupid) coercion rule (workaround):
JUEL:
http://juel.sourceforge.net/guide/advanced/index.html
TOMCAT:
http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html - COERCE_*
3) Use org.richfaces.component.Mode in AbstractDropDownMenu API:
EL 2.2 spec 1.18.6 Coerce A to an Enum Type T: "If A is null, return null" -
for Enum here is no coercion problem.
I would prefer solution 3) if possibible, because we use Java API directly
(menu.setMode(Mode.Server) is nicer and safer than a menu.setMode(Mode.server.name())
[1]
https://jsp-spec-public.dev.java.net/issues/show_bug.cgi?id=183
https://uel.dev.java.net/issues/show_bug.cgi?id=12
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira