let's say we have two types of events that will be directed to the same method as mentioned in the below example
<p:ajax event="cellEdit" listener="#{bean.eventype}"/>
<p:ajax event="change" listener="#{bean.eventype}"/>
and here is the bean method for example
public void eventype(){
println("");
}
The question is, is it possible if I want to identify which value came from which events in eventype method?
Is it possible to differentiate both mentioned events in eventype method?
Edited:
I did try to add eventype(AjaxBehaviorEvent event)
and use event.getSource() but it seems like am just getting the source details like org.inputtext.component@something
.
The type of event is posted in the request in order for the component being able to decode it to trigger the correct event. The parameter name is javax.faces.behavior.event
, which you can get like:
String eventType = FacesContext.getCurrentInstance()
.getExternalContext()
.getRequestParameterMap()
.get("javax.faces.behavior.event");
This is implemented in PrimeFaces like:
Note that you can also use the PrimeFaces constant Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM
in your code instead of hardcoding "javax.faces.behavior.event"
.