Websphere 7 JSF
在我的项目中,我们使用 JSF 1.2 和 JBOSS 5 开发了一个项目。作为新要求的一部分,我们必须将其迁移到 Websphere 7。但是我们面临着一个问题,我怀疑该问题与 WAS 内部使用的 java 运行时有关。 它无法自动装箱 int/Integers ,将 Strings 隐式转换为 long 。 在为其提供必要的检查后,我最终遇到了以下验证异常:
/Star/employeeFormP1.jsp(226,4) '#{StarEmployeeApplicationFormBean.medicalHMO}' Can't set property 'medicalHMO' on class 'com.idea .app.bean.StarEmployeeApplicationFormBean' 值为“true”。
以下是相关代码:
<h:selectBooleanCheckbox id="checkbox1"
value="#{StarEmployeeApplicationFormBean.medicalHMO}"
title="click it to select or deselect"
immediate="true"
valueChangeListener="#{StarEmployeeApplicationFormBean.listHMOMedProducts}"
onchange="return submit()" />
任何人都可以帮助我解决此验证异常吗?
In my project we have developed a project using JSF 1.2 and JBOSS 5. As part of new requirement we have to migrate it to Websphere 7. But we are facing a issue which I suspect is related to the java runtime being internally used by WAS. Its not able to autobox int/Integers , cast Strings to long implicitly. After providing the necessary checks for it finally I am stuck at the following validation exception:
/Star/employeeFormP1.jsp(226,4) '#{StarEmployeeApplicationFormBean.medicalHMO}' Can't set property 'medicalHMO' on class 'com.idea.app.bean.StarEmployeeApplicationFormBean' to value 'true'.
The following the relevant code:
<h:selectBooleanCheckbox id="checkbox1"
value="#{StarEmployeeApplicationFormBean.medicalHMO}"
title="click it to select or deselect"
immediate="true"
valueChangeListener="#{StarEmployeeApplicationFormBean.listHMOMedProducts}"
onchange="return submit()" />
Could anyone please help me on this validation exception?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
JBoss 5 和WebSphere 7 是JEE5 服务器,因此JSF 1.2 impl 将仅使用平台提供的EL 实现。 JSP 2.1 规范中详细介绍了类型强制转换的规则:
根据规范中详细的规则,这听起来像是 WebSphere 实现中的一个错误。 如果您找不到现有的 APAR/Fix Pack 解决了这个问题,我会报告它。
JBoss 5 and WebSphere 7 are JEE5 servers, so the JSF 1.2 impl will just be using the EL implementation provided by the platform. The rules for type coercion are detailed in the JSP 2.1 spec:
Based on the rules detailed in the spec, it sounds like a bug in the WebSphere implementation. If you can't find an existing APAR/Fix Pack that addresses the issue, I'd report it.
我不确定到底是什么问题。 我只有一些评论:
如果不发布一些代码,很难说清楚。
I'm not sure exactly what the problem is. I have just a few comments:
It's hard to tell without posting some code.
WAS 7.0 实际上使用 JDK 1.6,WAS 6.1 使用 JDK 1.5。
自动装箱对我有用,从 int 到 Integer 等。
我同意这样的评论:字符串到原始类型转换不是“自动装箱”的一部分。
MedicalHMO 的 setter 是您问题的关键,它期望什么类型?
例如,如果您有 setMedicalHMO(string newValue) { ... }
添加另一个设置器 setBooleanMedicalHMO(boolean newValue) { ... } 可能会很有趣
WAS 7.0 actually uses JDK 1.6, WAS 6.1 uses JDK 1.5.
Autoboxing works for me, int to Integer etc.
I agree with the comment that String to primitive type conversions are not part of "autoboxing".
The setter for medicalHMO is the key to your problem, what type does it expect?
If for, example, you have setMedicalHMO(string newValue) { ... }
it's might be interesting to add another setter setBooleanMedicalHMO(boolean newValue) { ... }
可能您正在使用 IBM JVM,不久前我注意到一个错误,如果您使用
==
将 int 与具有相同值的 long 进行比较,它会自动装箱并返回false
。例如,使用以下方法:
amIEqual(3,3)
在我使用的 IBM JVM 上为false
。为了解决这个问题,我显式地使用了对象类型:
现在,
amIEqual(3,3)
突然变成了true
。It may be you are using the IBM JVM I noticed a bug a while back where if you compare an int with a long with the same value using
==
it autoboxes and returnsfalse
.For example, using this method:
amIEqual(3,3)
wasfalse
on the IBM JVM I was using.To fix this, I explicitly used the object type:
Now,
amIEqual(3,3)
suddenly becametrue
.