Multiple events in the same p:ajax in PrimeFaces

六眼飞鱼酱① 提交于 2020-01-11 08:27:09

问题


Is it possible to have multiple events in the same p:ajax?

Something like this:

<p:ajax event="firstEvent,secondEvent..." listener="doSomething();" />

回答1:


I know it's later but I found and way to do this, You only need to put N tags of p:ajax, i.e:

<p:calendar id="startDate" value="#{bean.date}"
    pattern="dd.MM.yyyy"
    validator="#{bean.checkDate}">
    <p:ajax update="dialog:endDate" event="dateSelect"  /> 
    <p:ajax update="dialog:endDate" event="keyup"  /> 
</p:calendar>



回答2:


Faced with the same problem and came across this post. After trivial investigation, the "multiple events in the same p:ajax"-approach will not work. It is not supported at least for the tested Primefaces 5.3 version. An Exception like this will arise:

javax.faces.view.facelets.TagException: <p:ajax> Event:firstEvent,secondEvent is not supported.

Some source code from the AbstractBehaviorHandler class:

 ClientBehaviorHolder holder = (ClientBehaviorHolder) parent;

    String eventName = getEventName();

    if (null == eventName) {
        eventName = holder.getDefaultEventName();
        if (null == eventName) {
            throw new TagException(this.tag, "Event attribute could not be determined: "  + eventName);
        }
    } else {
        Collection<String> eventNames = holder.getEventNames();
        if (!eventNames.contains(eventName)) {
            throw new TagException(this.tag,  "Event:" + eventName + " is not supported.");
        }
    }


来源:https://stackoverflow.com/questions/35176380/multiple-events-in-the-same-pajax-in-primefaces

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!