Retrieving values from list in execute() method

耗尽温柔 提交于 2019-12-06 16:08:31

To submit the values to ArrayList you can use indexed property names. For example

<s:iterator value="exList" var="ex" status="status">
    <tr>
        <td><s:property value="name"/></td>
        <td><s:textfield cssClass="num" name="exList[%{status.index}].name" onchange="calculateSum()"/></td>
    </tr>
</s:iterator>

You should also provide a conversion configuration for the bean Ex. Assume the property name is inside the bean.

@Element(value = Ex.class)
@Key(value = String.class)
@KeyProperty(value = "name") 
@CreateIfNull(value = true)
private ArrayList<EX> exList;

Note that some annotations you can omit, because might be the key is not used or the value is used by default, but it's configurable in all cases. More about this conversion technique you can find in the docs Advanced Type Conversion.

EDIT:

One more thing EX != Ex and it should be public class not an inner class. Having to set float values check that you don't have conversion errors.

Remove action="ex" from

<s:submit  action="ex" value="SUBMIT"/>

because on submit click form action calls. no need to give action="ex" in submit button.

Close </package> tag.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!