Validate input as required only if certain command button is pressed

后端 未结 2 1497
死守一世寂寞
死守一世寂寞 2021-02-06 06:51

I have specific use case for JSF validation. For example I have an inputText field:



        
2条回答
  •  情深已故
    2021-02-06 07:19

    Let the input's required attribute check if the save button is pressed or not (which can be identified by the presence of its client ID in the request parameter map).

    
        
    
        
    
    

    (note: do not bind it to a bean property! the code is as-is)

    This way it would only evaluate true when the save button is actually pressed.

    Or, if you have problems with binding and/or don't have a problem hardcoding the button's client ID:

    
        
    
        
    
    

提交回复
热议问题