We normally do this in the formBackingObject method. Something like this. For the objects to still be there make sure you have turned the sessionForm property to true. Either by configuration or by using setSessionForm in the constructor of your controller.
Code:
protected Object formBackingObject(HttpServletRequest request) throws Exception {
YourCommandObject command = new YourCommandObject();
YourObjectInList objInList1 = new YourObjectInList();
YourObjectInList objInList2 = new YourObjectInList();
YourObjectInList objInList3 = new YourObjectInList();
command.addObjectToList(objInList1);
command.addObjectToList(objInList2);
command.addObjectToList(objInList3);
return command;
}
Then in your onSubmit or onBindAndValidate remove the rows you don't need.
Code:
protected void onBindAndValidate(HttpServletRequest request, Object command, BindException errors) {
YourCommandObject object = (YourCommandObject) command;
Iterator it = object.getListWithObjects().iterator;
while (it.hasNext()) {
YourObjectInList listObject = (YourObjectInList) it.next();
if (listObject.checkSomeValue() ) {
it.remove();
}
}
}