Websphere 7 JSF

发布于 2024-07-29 19:17:36 字数 754 浏览 4 评论 0原文

在我的项目中,我们使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

孤独难免 2024-08-05 19:17:36

JBoss 5 和WebSphere 7 是JEE5 服务器,因此JSF 1.2 impl 将仅使用平台提供的EL 实现。 JSP 2.1 规范中详细介绍了类型强制转换的规则:

例如,如果将 int 强制转换为 String,则将 int “装箱”为 Integer,并应用将 Integer 强制转换为 String 的规则。 或者,如果将字符串强制转换为双精度值,请应用将字符串强制转换为双精度值的规则,然后“拆箱”生成的双精度值,确保生成的双精度值实际上不为空。

根据规范中详细的规则,这听起来像是 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:

For example, if coercing an int to a String, "box" the int into an Integer and apply the rule for coercing an Integer to a String. Or if coercing a String to a double, apply the rule for coercing a String to a Double, then "unbox" the resulting Double, making sure the resulting Double isn’t actually null.

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.

素年丶 2024-08-05 19:17:36

我不确定到底是什么问题。 我只有一些评论:

  1. “...它无法自动装箱 int/Integers...” - Google 告诉我 WAS 7 使用 JDK 5,自动装箱。 也许您应该检查以确保您的应用程序服务器使用正确版本的 JVM。
  2. “...将字符串隐式转换为 long...” - 我不相信任何 JVM 会这样做。

提供必要的检查后
为此我最终陷入了困境
以下验证异常:

/Star/employeeFormP1.jsp(226,4)
'#{StarEmployeeApplicationFormBean.medicalHMO}'
无法将属性“medicalHMO”设置为打开
班级
'com.idea.app.bean.StarEmployeeApplicationFormBean'
值“true”。

如果不发布一些代码,很难说清楚。

I'm not sure exactly what the problem is. I have just a few comments:

  1. "...it's not able to autobox int/Integers..." - Google tells me that WAS 7 uses JDK 5, which does autoboxing. Perhaps you should check to make sure your app server is using the right version of JVM.
  2. "...cast Strings to long implicitly..." - I don't believe any JVM does this.

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'.

It's hard to tell without posting some code.

小傻瓜 2024-08-05 19:17:36

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) { ... }

自我难过 2024-08-05 19:17:36

可能您正在使用 IBM JVM,不久前我注意到一个错误,如果您使用 == 将 int 与具有相同值的 long 进行比较,它会自动装箱并返回 false

例如,使用以下方法:

public boolean amIEqual(int myInt, long myLong){
     return myInt == myLong;
}

amIEqual(3,3) 在我使用的 IBM JVM 上为 false

为了解决这个问题,我显式地使用了对象类型:

public boolean amIEqual(Integer myInt, Long myLong){
     return myInt.equals(myLong);
}

现在,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 returns false.

For example, using this method:

public boolean amIEqual(int myInt, long myLong){
     return myInt == myLong;
}

amIEqual(3,3) was false on the IBM JVM I was using.

To fix this, I explicitly used the object type:

public boolean amIEqual(Integer myInt, Long myLong){
     return myInt.equals(myLong);
}

Now, amIEqual(3,3) suddenly became true.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文