p:commandButton vs. h:commandButton

前端 未结 1 1367
轻奢々
轻奢々 2020-11-29 12:27

When I am using a PrimeFaces p:commandButton


I don\'t see the the validation m

1条回答
  •  再見小時候
    2020-11-29 13:22

    Like @Partlov wrote in the comments below the question,

    Main difference is that p:commandButton is AJAX by default, and h:commandButton is non-AJAX by default.

    So

    
    

    is more like

    
        
    
    

    but

    
        
    
    

    is wrong and leads to undefined behaviour

    or the other way around

    
    

    is like

    
    

    The p:commandButton will submit the form by default. However by default it does not update anything in the form after the ajax call is finished so the messages are not displayed (which in development mode would have shown in the log files that messages were enqueued but not displayed) . The non-ajax h:commandButton does a full page refresh that does show the messages. In order to get the form (which contains the message component) updated when using the p:commandButton you need to add the update attribute:

    
        
    
    

    Adding an (superfluous) f:ajax or p:ajax inside a p:commandXXX can result in strange undefined behaviour

    See also

    • Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes

    0 讨论(0)
提交回复
热议问题