« Return to Thread: html:multibox read but not write
I am in very strange situation, and stuck! please help, I have found one thread that much more or less but does not help..
http://www.nabble.com/Check-a-multibox-dynamically-to6630704.html#a6630704I have already use some example and it works.. Now the situation is lsightly different:
I have a form:
------------ Start Code ------------
... FunctionProForm extends ActionForm {
private List functionProList = new ArrayList();
...
public List getSelectedPros(FunctionDto fun){
List result = new ArrayList();
for(FunProMap fp : functionProList){
if(fp.getFunction().getName().equals(fun.getName())){
for(int i = 0; i < fp.getSelectedPros().length; i++){
result.add(fp.getSelectedPros()[i]);
}
return result;
}
}
return result;
}
}
------ the serializable object FunProMap ------------------
public class FunProMap implements Serializable{
private static final long serialVersionUID = 1L;
private FunctionDto function = new FunctionDto();
private List pros = new ArrayList();
private String[] selectedPros = {};
...
}
--------------- in JSP: -------------
<table>
<logic:iterate id="funPro" name="funProForm" property="functionProList ">
<tr>
<td>
<table border="0">
<tr>
<logic:iterate id="pro" name="funPro" property="pros">
<td>
<html:multibox name="funPro" property="selectedPros">
<bean:write name="pro" property="label" />
</html:multibox>
</td>
</logic:iterate>
<tr>
</table>
</td>
</tr>
</table>
--------------------- in the SaveAction ----------------------
... SaveAction extends Action {
protected ActionForward doExecute(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse response){
FunctionProForm myForm = (FunctionProForm) form;
...
List functions = myService.listFunctions();
for(FunctionDto fun : functions){
fun.setPros(myForm.getSelectedPros(fun));
myService.updateFunction(fun);
}
....
return mapping.findForward("success");
}
}
------------ End Code ------------
The check boxes are populated correctly from the database, i.e. for each FUnction, the corresponding checkbos is checked according to the list of available Pros (function.pros).
The problem is that if I edit these boxes, check and uncheck, and click the Submit button, the changed is not saved to the database.
I have run the debug and find that the method myForm.getSelectedPros(fun) returns the old values but not the new checked-unchecked boxes' values :-( !!
I have used and
and this works fine..
Please help...
houser
MyForm extends ActionForm {
List
<logic:iterate id="item" name="myForm" property="myList">
<td>
<html:multibox property="selectedValues">
<bean:write name="item" property="label" />
</html:multibox>
</td>
</logic:iterate>
« Return to Thread: html:multibox read but not write
| Free Forum Powered by Nabble | Forum Help |