myfaces - h:selectOneMenu 在 Myfaces 从 1.1.4 升级到 1.1.8 后不起作用
问题描述
我正在使用 JSF 1 并尝试将 Myfaces 版本从 1.1.4 更新到 1.1.8 我在 myxhtml 页面中有类似的内容,
<h:selectOneMenu id="orgCountry" value="#{crud.orgAddress.country}
<f:selectItem itemLabel="#{messageResources.dropDownPleaseSelect}" itemValue=""/>
<f:selectItem itemLabel="#{crud.usrbld.countryName}" itemValue="#{crud.usrbld.countryId}"/>
<f:selectItems value="#{getSelectItems('countryDAOCrud')}"/>
<a4j:support id="countryDropDown" event="onchange" ajaxSingle="true" reRender="orgState" oncomplete="updateStateDropdown()"/>
</h:selectOneMenu>
getselectItems 是一个普通的方法,
getselectItems (){
list= gettingfromDB
converting into selectItem type
country 是一个普通的 pojo 类,带有 hash 和 equals 方法
使用 Myfaces 1.1.4 时,一切正常,但升级到 Myfaces 1.1.8 时,我的提交失败,这是由于验证错误,即 ParametrizableFacesMessage "{0}": Value is not a valid option .
此错误的原因是 _SelectItemUtil 中的 matchvalue 方法,即,
Object itemValue = item.getValue();
if (value==itemValue || (itemValue.equals(value)))
{
return true;
}
所以这里的值是从下拉列表中选择的值,itemValue 是 SelectItem 的项目之一(这是在迭代器循环中),这里的值是我的类类型,itemValue 是字符串,因为它们从不匹配验证总是失败。而在 Myfaces 1.1.4 中, itemValue 被转换为类对象类型,因此比较返回成功。我将无法升级 JSF 版本。任何人都可以帮我解决这个问题。在此先感谢。
解决方案
我不得不覆盖jar方法来解决这个问题
推荐阅读
- python - 我如何提取只有 HTML 标签的内容
- python - 在numpy中使用什么函数来获得以下结果
- python - 在熊猫中应用groupby后如何计算列的正数和负数
- c++ - 因特定情况而失败
- php - 如何处理 laravel 中的页面崩溃?
- latency - 从 Cloud Tasks 调用 Cloud Run 时出现高延迟
- yaml - 控制 YAML 中字段顺序的规则
- reactjs - 将自定义 makeStyles 的优先级设置为高于 MUI 样式 #21199
- python - ModuleNotFoundError: No module named 'surprise' and others(我有各种版本的 python)
- javascript - Angular 嵌套命名的 Outlets 路由