I'm trying to pass the value from JSP page to my Action class when pressing the Update button.
In this case, I create in action class a list of Strings named value
with getter and setter.
My problem is that, when trying to modify the input field in JSP and then pressing Update, value
remains the same (with its initial value) in the action class.
For example:
v[0] = "zero"
v[1] = "something"
v[2] = "true"
In my form I've changed the v[2]
input text in "false"
and then pressed Update; when printed in execute()
, v[2]
remains "true"
.
UPDATE: I rewrite the JSP code, using Struts 2 tag instead of scriptlet
<form name="propertiesForm" method="post" action="<s:url value='/update.action'/>" >
<table>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
<s:iterator value="%{propertiesForm.properties}" status="rowStatus">
<tr>
<td><s:property value="%{properties[#rowStatus.index].name}"/></td>
<td><s:textfield name="value[%{#rowStatus.index}]" value="%{propertiesForm.getValue(#rowStatus.index)}"/></td>
</tr>
</s:iterator>
<tr>
<td><input class="buttons" type="submit" value="Update" /></td>
</tr>
</table>
</form>