Hi, everyone.

I am using Struts 2: action with parameters interceptor. My action has some
optional properties of type Short(e.g. "currency"). When i submit form, the
"currency" value arrived into Struts framework equals to empty string - "".

Struts 2 tries to construct Short value from empty string, fails and reports
validation error. It's inappropriate, since i want the property to be
optional. It would be absolutely perfect if the conversion error is simply
ignored and "currency" property value remains default (null).

I've googled the question, and found, that Struts2(more precisely, XWork)
supports it:

http://struts.apache.org/2.0.6/struts2-core/apidocs/com/opensymphony/xwork2/util/XWorkConverter.html
"...MessageFormat object) to see how a properly formatted date should be
displayed.

Any error that occurs during type conversion may or may not wish to be
reported. For example, reporting that the input "abc" could not be converted
to a number might be important. On the other hand, reporting that an empty
string, "", cannot be converted to a number might not be important -
especially in a web environment where it is hard to distinguish between a
user not entering a value vs. entering a blank value.

By default, all conversion errors are reported using the generic i18n
key..."

Well, yeah! It's really great! I know now, that it is possible with Struts
2. Cool. Very useful. :-D

The very-very small question remains: HOW? 
What should i do to force Struts 2 to ignore "empty string ->
java.lang.Short" conversion errors?

Thanks.
-- 
View this message in context: 
http://www.nabble.com/Struts2---Force-it-to-ignore-%22empty-string--%3E-number%22-conversion-error-tp22231780p22231780.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to