为什么我的f:ajax无法与h:selectOneMenu一起使用?

编程入门 行业动态 更新时间:2024-10-10 19:27:52
本文介绍了为什么我的f:ajax无法与h:selectOneMenu一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用JSF 2.0,Glassfish 3.2,Primefaces 2.2.1

Using JSF 2.0, Glassfish 3.2, Primefaces 2.2.1

我有一个包含多个复合组件的页面.在这些组件之一中,我有一个h:selectOneMenu.我正在尝试添加f:ajax以在选择新值时调用方法.

I have a page with several composite components. In one of these components, I have an h:selectOneMenu. I am trying to add f:ajax to call a method when a new value is selected.

这是页面中的h:selectOneMenu组件的样子:

Here is what the h:selectOneMenu component in the page looks like:

<h:selectOneMenu id="selectRmDD" styleClass="editSelectRmDD" value="#{scheduleEditSessionBean.selectedRoom}" > <f:selectItems id="roomList" value="#{scheduleEditSessionBean.roomList}"/> <f:ajax listener="#{scheduleEditSessionBean.selectRmDD_processValueChange}" event="valueChange" render="@form" /> </h:selectOneMenu>

当我从h:selectOneMenu中选择一个新项目时,将调用侦听器函数,但 selectedRoom 中的值将为null.我也在调试器中进行了查看,甚至AjaxBehaviorEvent中组件的SubmittedValue也为null.这是在选择新值和selectedRoom的定义时调用的方法:

When I select a new item from the h:selectOneMenu, the listener function gets called, but the value in selectedRoom is null. I have looked at this in the debugger as well and even the submittedValue for the component in the AjaxBehaviorEvent is also null. Here is the method that is called when a new value is selected and the definition for selectedRoom:

public void selectRmDD_processValueChange( AjaxBehaviorEvent ae) { String s = getSelectedRoom(); System.out.println( "Selected room = "+s ); if( s != null )applyRoomBtn_action(); } private String selectedRoom = "1"; public String getSelectedRoom() { return this.selectedRoom; } public void setSelectedRoom(String s) { this.selectedRoom = s; }

有什么想法为什么不能满足您的要求?

Any ideas why the value isn't being filled?

谢谢.

推荐答案

在处理表单提交时,当roomList的SelectItem具有null或空字符串作为值时,将发生这种情况.没有其他原因出现,可以预期String.class的Converter不能正常工作,但是应该会影响绑定到String属性的所有输入.

That will happen when the SelectItem of the roomList has null or empty string as value at the point the form submit is been processed. No other causes comes to mind, expect of maybe a Converter for String.class which is not doing its job properly, but that should have affected all inputs which are bound to a String property.

更多推荐

为什么我的f:ajax无法与h:selectOneMenu一起使用?

本文发布于:2023-11-24 19:41:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626557.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ajax   selectOneMenu

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!