How to know which component triggerd an p:ajax request

前端 未结 2 1766
有刺的猬
有刺的猬 2021-01-27 07:58

I have multiple input field with a p:ajax with a listener. They all connect to the same listener. How can I know what component triggerd the listener?



        
2条回答
  •  醉酒成梦
    2021-01-27 08:41

    It is almost same in primefaces:

     
    
    
    import javax.faces.event.AjaxBehaviorEvent;
    .....
    public void retrievePostalCodeCity(AjaxBehaviorEvent event) {
    ...
    }
    

    If you want to access via button component action/actionListener tag you can use ActionEvent and for any case make sure you set ajax="true":

    
    
    import javax.faces.event.ActionEvent;
    
    ....
    
    public void retrievePostalCodeCity(ActionEvent event) {
        ...
        }
    

提交回复
热议问题