Hi
I am using Stripes for a project and have a situation I cannot understand. In my action bean I have a list of objects (for setting app config params) and in the jsp I am dynamically creating input fields for each object. For a normal edit everything works fine however if I try and set a field to empty the object value remains what it was previously. I have looked extensively through the code and am confident it is not being done by any of the code we have written. When I debug I can see that the setValue() method of my object is being called for all configuration objects except the one that is blank, rather than setValue being called with an empty string which is what I would expect.
Does anyone know if Stripes is doing something under the hood which is affecting this?
Thanks
Snippets of Code:
Object code:
public class Configuration implements Serializable {
@Id
@Basic(optional = false)
@Column(name = "id", nullable = false)
private Integer id;
@Basic(optional = false)
@Column(name = "name", nullable = false, length = 100, updatable = false)
private String name;
@Basic(optional = true)
@Column(name = "value", nullable = true, length = 200)
private String value;
...
public void setValue(String value) {
//This is never called when I empty my input field
this.value = value;
}
...
}
Action Bean Code:
public class ConfigActionBean extends BaseActionBean {
private List<Configuration> allConfigurationEntries;
@Before(stages = LifecycleStage.BindingAndValidation)
public void rehydrate() {
allConfigurationEntries = configurationService.getAllEntries();
}
@DefaultHandler
public Resolution view() {
return new ForwardResolution(
"/WEB-INF/jsp/admin/configuration.jsp");
}
public Resolution Save() {
configurationService.saveAllEntries(allConfigurationEntries,is);
return new RedirectResolution(ConfigActionBean.class,"view");
}
public void setAllConfigurationEntries(
List<Configuration> allConfigurationEntries) {
this.allConfigurationEntries = allConfigurationEntries;
}
public List<Configuration> getAllConfigurationEntries() {
return allConfigurationEntries;
}
...
}
View JSP Code:
...
<c:forEach items="${actionBean.allConfigurationEntries}" var="items" varStatus="loop">
<div>
<s:label for="allConfigurationEntries[${loop.index}].value">${items.name}</s:label>
<s:text id="${items.name}" name="allConfigurationEntries[${loop.index}].value" value="${items.value}" />
</div>
</c:forEach>
...