Multiple events in the same p: ajax in PrimeFaces

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

Something like that:

<p:ajax event="firstEvent,secondEvent..." listener="doSomething();" />
+4
source share
2 answers

I know this later, but I found a way to do it, you only need to put N tags from p: ajax, ie:

<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
source

Faced with the same problem and faced with this message. After a trivial study, "multiple events in the same p: ajax" approach will not work. It is not supported, at least for the tested version of Primefaces 5.3. The following exception occurs:

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

Source code from the class AbstractBehaviorHandler:

 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.");
        }
    }
+1
source

Source: https://habr.com/ru/post/1627136/


All Articles