struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J. Garcia" <jogaco...@gmail.com>
Subject conversion error repopulation not working
Date Wed, 23 May 2012 18:34:10 GMT
Hi,

In order to implement a good user experience, I am trying to put into
practice the conversion validator, as documented here:

http://struts.apache.org/2.3.3/docs/conversion-validator.html

The ideal would be: a form with one integer field. If the user enters a non
valid integer, the value remains in the input field and the user is
informed of the error like this:
Invalid value '198o' for field 'Year'. (notice the letter at the end).

For this, I declare the conversion-validator, and have to remove the
conversionError from the interceptors stack.
While debugging, the class ConversionErrorFieldValidator builds a map, with
the full fieldName and the entered value.
The method repopulateField from
RepopulateConversionErrorFieldValidatorSupport is run, which in theory
repopulates the stack with this code:

            if (doExprOverride) {
                invocation.addPreResultListener(new PreResultListener() {
                    public void beforeResult(ActionInvocation invocation,
String resultCode) {
                        ValueStack stack =
ActionContext.getContext().getValueStack();
                        stack.setExprOverrides(fakeParams);
                    }
                });
            }

However, when showing the jsp for user input, the invalid value is not in
the form input field. It does not seem to work as documented in the
mentioned url.

Cheers,
J.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message