On 10/4/2017 9:19 AM, sreekanth wrote:
> thanks Yasser, that info was great, so do you think so the way struts2 binds
> BigDecimal changed between these two versions ?

I found the difference at [1]. That is in order to fix WW-4581 [2].

[1] 
https://gitbox.apache.org/repos/asf?p=struts.git;a=commitdiff;h=f874f9cde56f74c5161b17e645f779805c51a04b
[2] https://issues.apache.org/jira/browse/WW-4581

>  and also if possible kindly
> share your sample project in github so that i can fork it and check myself
> faster.
> 

My sample is inside a big project like a big Struts lab ;) but the 
config is simple as below:

```java
package me.zamani.yasser.ww_convention.actions;

import java.math.BigDecimal;

/**
  * Created by user on 10/3/2017.
  */
public class A {
         public String getStrVal() {
             return strVal;
         }

         public void setStrVal(String strVal) {
             this.strVal = strVal;
         }

         public BigDecimal getDrAmt() {
             return drAmt;
         }

         public void setDrAmt(BigDecimal drAmt) {
             this.drAmt = drAmt;
         }

         public BigDecimal getCrAmt() {
             return crAmt;
         }

         public void setCrAmt(BigDecimal crAmt) {
             this.crAmt = crAmt;
         }

         String strVal;
         BigDecimal drAmt;
         BigDecimal crAmt;
     }
```

```java
package me.zamani.yasser.ww_convention.actions;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;

@Results({
         @Result(name = Action.SUCCESS, location = 
"/WEB-INF/content/myBigDecimalList.jsp"/*, type = "freemarker"*/)
})
public class MyBigDecimalList extends ActionSupport {

     public List<A> getMyList() {
         return myList;
     }

     public void setMyList(List<A> myList) {
         this.myList = myList;
     }

     private List<A> myList;

 
@org.apache.struts2.convention.annotation.Action(value="myBigDecimalList")
     public String execute() throws Exception {
         A a = new A();
         a.setStrVal("my str val");
         a.setCrAmt(new 
BigDecimal("0.01000000000000000020816681711721685132943093776702880859375"));
         a.setDrAmt(new 
BigDecimal("0.02000000000000000020816681711721685132943093776702880859375"));
         myList=new ArrayList<>();
         myList.add(a);
         NumberFormat format = NumberFormat.getNumberInstance(getLocale());
         //NumberFormat.set
         format.setMaximumFractionDigits(40);
         return Action.SUCCESS;
     }
}

```

```jsp
<%@taglib prefix="s" uri="/struts-tags"%>
<%--
   Created by IntelliJ IDEA.
   User: user
   Date: 8/18/2017
   Time: 12:36 AM
   To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
     <title>AdvancedWildcardAction1</title>
</head>
<body>
<s:form action="myBigDecimalList">
<s:hidden name='myList[0].strVal'/>
<s:hidden name='myList[0].drAmt'/>
<s:hidden name='myList[0].crAmt'/>
     <s:submit/>
</s:form>
</body>
</html>
```

Hope these help!
Yasser.

> 
> 
> --
> 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
> 

Reply via email to