user4372614
user4372614

Reputation: 25

Xpages - blank fields overwritten with value saved in document if validation fails

Im making an Xpages application which needs to have server-side validation.

In my form, when a field is cleared and the form submitted - if there is another field which causes the validation to fail - it will be repopulated with the last successfully saved value in the document.

This is not what should happen. The field should stay blank until the page is either refreshed, or the user enters another value.

Does anyone have any idea about what is causing this to happen?

Thanks, Paul

Upvotes: 1

Views: 234

Answers (2)

user4372614
user4372614

Reputation: 25

Thanks for the help. As far as I can tell, it was simply due to the way the default converter included with xpages handles the object and/or string. Writing a java custom converter sorted everything out.

Upvotes: 0

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15729

This depends on your execId and refreshId.

For what happens during partial refresh, read these blog posts, particularly part three http://www.intec.co.uk/tag/partial-refresh/.

If validation (or conversion) fails server-side, the server-side map of the XPage is not updated because the data is not deemed complete enough for server-side processing.

So the partial refresh skips to Render Response, which posts back what HTML should be displayed to the page. That includes values in fields - you're replacing HTML, so it has to.

If you're save button is refreshing the form area, you'll be replacing the HTML there, so overwriting the values entered by the user with the last valid values.

The recommended approach will depend on your page architecture and what you're saving. One is to move validation to the save() function, by which time the values will have been updated in the DominoDocument (the front-end wrapper for the Document on the server). Another is to only refresh the validation area and, if validation was successful, call context.reloadPage() or context.redirectToPage() to effectively skip the partial refresh.

Upvotes: 2

Related Questions