为什么我的f:ajax无法与h:selectOneMenu一起使用? [英] Why doesn't my f:ajax work with h:selectOneMenu?

查看:117
本文介绍了为什么我的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?

谢谢.

推荐答案

在处理表单提交时,当roomListSelectItem具有null或空字符串作为值时,将发生这种情况.没有其他原因出现,可以预期String.classConverter不能正常工作,但是应该会影响绑定到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一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆