On 10/4/2017 10:45 AM, sreekanth wrote: > thanks Yasser, let me setup a sample too. I already went through fixes > introduced at WW-4581 as well and ran a test against it and found that's not > the reason for this behavior rather something related to form field binding. > > Here i'm adding your finding which i too believe the root cause for this new > behavior. > > * > 2.5.13. But now I also tested 2.5.10.1 and get following warn when try > to set empty string value to a BigDecimal: > > Unexpected Exception caught setting 'myList[0].crAmt' on 'class > me.zamani.yasser.ww_convention.actions.MyBigDecimalList: Error setting > expression 'myList[0].crAmt' with value ['', ] > * >
This is because of line#93 [1] in Struts 2.5.13: ```java return format.parse(strValue); ``` Currently it cannot parse empty values to 0 as java's DecimalFormat class cannot. Maybe we can change the behavior by replacing any empty with "0" in Strut's future versions ?! Until that time, I think you can extend NumberConverter and override it's convertToBigDecimal method and use it instead (see also [2]): ```java @override protected Object convertToBigDecimal(context,value) { String strValue = String.valueOf(value); if(null==value || strValue.isNullOrEmpty()) strValue="0"; return super.convertToBigDecimal(context,strValue); } ``` Hope these help! Yasser. [1] https://gitbox.apache.org/repos/asf?p=struts.git;a=blob;f=core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java;h=16bbd499e00f03d4a673cd43d90dc261db3849df;hb=f874f9cde56f74c5161b17e645f779805c51a04b#l93 [2] https://saifmasadeh.blogspot.com/2012/10/custom-converter-for-bigdecimal-struts2.htm > > > -- > Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org >