随笔-348  评论-598  文章-0  trackbacks-0
今天开发的测试的时候碰到一个问题,就是用Myfaces的SelectOneRadio空间的时候,页面第一次展现没问题,当我使用上一步切换tab再下一步的时候就抛出了异常,异常如下:
Caused by: javax.faces.convert.ConverterException: java.lang.ClassCastException: org.apache.myfaces.shared_impl.renderkit.RendererUtils$1
cannot be cast to java.lang.Boolean
at javax.faces.convert.BooleanConverter.getAsString(BooleanConverter.java:91)
at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedStringValue(RendererUtils.java:630)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlRadioRendererBase.encodeEnd(HtmlRadioRendererBase.java:91)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:624)
... 110 more
Caused by: java.lang.ClassCastException: org.apache.myfaces.shared_impl.renderkit.RendererUtils$1
cannot be cast to java.lang.Boolean
at javax.faces.convert.BooleanConverter.getAsString(BooleanConverter.java:87)
... 113 more

后来在国外网站上面找到了问题所在:

Hello,

the problem still exists in MyFaces Core 1.2.6.

I have a selectOneMenu with a value binding to a boolean property.

In the boolean converter the ClassCastException still occurs.

...
Caused by: javax.faces.convert.ConverterException: java.lang.ClassCastException: org.apache.myfaces.shared_impl.renderkit.RendererUtils$1
cannot be cast to java.lang.Boolean
at javax.faces.convert.BooleanConverter.getAsString(BooleanConverter.java:91)
at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedStringValue(RendererUtils.java:630)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlRadioRendererBase.encodeEnd(HtmlRadioRendererBase.java:91)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:624)
... 110 more
Caused by: java.lang.ClassCastException: org.apache.myfaces.shared_impl.renderkit.RendererUtils$1
cannot be cast to java.lang.Boolean
at javax.faces.convert.BooleanConverter.getAsString(BooleanConverter.java:87)
... 113 more

In RendererUtils there are some tests that value equals NOTHING. However the equals method
of the NOTHING-Serializable isn't overriden. Therefore it has no effect.

Overriding the equals method as in the patch of paul works.


有些东西没有实现,导致了这个问题。这个可能需要你自己简单实现一下源文件然后编译成库文件了,感觉麻烦就换成了SelectOneMenu了。
后面有时间再看了





---------------------------------------------------------
专注移动开发

Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
posted on 2009-12-03 20:34 TiGERTiAN 阅读(1308) 评论(0)  编辑  收藏 所属分类: JavaJSF

只有注册用户登录后才能发表评论。


网站导航: