< F:AJAX>在PrimeFaces组件上不起作用 [英] <f:ajax> doesn't work on PrimeFaces component

查看:135
本文介绍了< F:AJAX>在PrimeFaces组件上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用 onChange 事件 selectOneMenu ,但它不起作用,组件不是当我添加 onChange attribue时显示。



有人可以告诉我如何处理 onChange 事件< p:selectOneMenu>



这是我的观点:

 < p:selectOneMenu id =servicefilterMatchMode =startsWith> 
< f:selectItem itemLabel =Selectionner un Service:/>
< f:selectItems value =#{newOpProgramme.listeSevice}var =serviceitemValue =#{service.serviceId}itemLabel =#{service.serviceNom}/>
< f:ajax event =changeexecute =@ thislistener =#{newOpProgramme.serviceChange()}render =nomCdp/>
< / p:selectOneMenu>

这里是< f:ajax listener> 方法在一个请求作用域bean中:

  public void serviceChange(){
System.out.println 更改);
}

然而,当我更改菜单时,没有打印任何内容。 >

这是如何引起的,如何解决?

解决方案

所有, onChange 是错误的事件名称。 更改。其次,如果您打算调用HTML属性名称, onChange 也是错误的属性名称。 onchange



回到你的具体问题;标准JSF < f:ajax> 与PrimeFaces组件不兼容。您应该使用PrimeFaces自己的 < p:ajax>

 < p:selectOneMenu ...> 
...
< p:ajax listener =#{newOpProgramme.serviceChange()}update =nomCdp/>
< / p:selectOneMenu>

请注意,我省略了事件 进程属性。它们都分别具有正确的默认值 valueChange @this



另请参见:




I trying to use the onChange event of selectOneMenu, but it doesn't work and the component is not displayed when I add onChange attribue.

Can someone tell me how can I handle the onChange event of <p:selectOneMenu>?

Here is my view:

<p:selectOneMenu id="service" filterMatchMode="startsWith">  
    <f:selectItem itemLabel="Selectionner un Service : "  />  
    <f:selectItems value="#{newOpProgramme.listeSevice}" var="service" itemValue="#{service.serviceId}" itemLabel="#{service.serviceNom}"/>
    <f:ajax event="change" execute="@this" listener="#{newOpProgramme.serviceChange()}" render="nomCdp"/>
</p:selectOneMenu>

And here is the <f:ajax listener> method in a request scoped bean:

public void serviceChange() {
    System.out.println("change");
}

When I change the menu, however, nothing is been printed.

How is this caused and how can I solve it?

解决方案

First of all, onChange is the wrong event name. It's change. Secondly, if you intend to call the HTML attribute name, onChange is also the wrong attribute name. It's onchange.

Coming back to your concrete problem; the standard JSF <f:ajax> is not compatible with PrimeFaces components. You should be using PrimeFaces own <p:ajax> instead.

<p:selectOneMenu ...>
    ...
    <p:ajax listener="#{newOpProgramme.serviceChange()}" update="nomCdp" />
</p:selectOneMenu>

Note that I omitted the event and the process attributes. They both have already the right default value of valueChange and @this respectively.

See also:

这篇关于&LT; F:AJAX&GT;在PrimeFaces组件上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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