1

I'm using the <f:validateWholeBean> tag (JSF 2.3) for class-level validation.

The validation is occurring correctly, however, the form data is deleted after the return of the messages with the validation errors.

From what I realized this is the default behavior, but I wanted to know if it is possible to do different, I want the data to remain in the form after the restore view phase. I want the user to see the information that was entered wrong.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102

1 Answers1

0

I was able to solve my problem by using the <o: validateBean value =" # {bean.product} "/> omnifaces tag in conjunction with the method attribute to" validateActual ". The reported behavior as disadvantage in documentation is ideal for me.

If the copying strategy is not possible due to technical limitations, then you could set method attribute to "validateActual".

<o:validateBean value="#{bean.product}" validationGroups="com.example.MyGroup" method="validateActual" />

This will update the model values and run the validation after update model values phase instead of the validations phase. The disadvantage is that the invalid values remain in the model and that the action method is anyway invoked. You would need an additional check for FacesContext.isValidationFailed() in the action method to see if it has failed or not.

http://showcase.omnifaces.org/validators/validateBean