JSF skip Required-Validation without immediate=true

后端 未结 6 1307
余生分开走
余生分开走 2020-12-04 12:11

I have multiple forms, where I have mandatory fields and optional fields.

To submit such a form I require the validation on the required-attribute to be exe

6条回答
  •  旧巷少年郎
    2020-12-04 12:49

    Each Button creates an entry inside the Param-List as long as it's member of the form. So I simple applied a check for the presence of that entry to the "required" parameter:

    
    ...
    
    ...
    
    
    
    
    

    When I click "Submit" the param['form:save'] is NULL, which then turns the expression to true so the validation is executed.

    When I click "Save" the param['form:save'] is NOT NULL (but empty!), which resolves to false so the validation is ignored. (Or let's say JSF thinks it is not a required field due to the expression beeing evaluated to false)

提交回复
热议问题