[Struts][JSP] Multibox cochée par défaut
Bonjour,
J'avais déjà fait ça mais là ça ne marche pas et je ne comprends pas.
Voici mon struts-config.xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <form-bean
name="adminUserForm"
type="fr.webshop.admin.form.AdminUserForm" >
</form-bean>
<action path="/admin/manageUsers"
type="fr.webshop.admin.action.manageUsersAction"
name="adminUserForm"
validate="false">
<forward name="error" path="/admin/error.jsp" />
<forward name="success" path="/admin/displayUsers.jsp" />
<action path="/admin/bannedUser"
type="fr.webshop.admin.action.BannedUserAction"
name="adminUserForm"
scope="request"
input="/admin/manageUsers.do"
validate="false">
<forward name="error" path="/admin/error.jsp" />
<forward name="success" path="/admin/manageUsers.do" />
</action>
</action> |
Ma classe AdminUserForm:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| private String[] checkedBox;
private String[] box;
/**
* @return Returns the checkedBox.
*/
public String[] getCheckedBox() {
return checkedBox;
}
/**
* @param checkedBox The checkedBox to set.
*/
public void setCheckedBox(String[] checkedBox) {
this.checkedBox = checkedBox;
}
/**
* @return Returns the formBox.
*/
/**
* @return Returns the box.
*/
public String[] getBox() {
return box;
}
/**
* @param box The box to set.
*/
public void setBox(String[] box) {
this.box = box;
} |
Ma classe manageUsersAction:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| ...
String[] checkedBox = new String[3];//[nbUsers];
checkedBox[2]="Rene";
checkedBox[1]="Gerard";
checkedBox[0]="Claude";
String[] box = new String[3];//[nbUsers];
box[2]="Rene";
box[1]="Gerard";
box[0]="Claude";
AdminUserForm myForm = (AdminUserForm)form;
myForm.setCheckedBox(checkedBox);
myForm.setBox(box);
... |
et enfin la jsp :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| <logic:present name="adminUserForm" property="box" >
<logic:notEmpty name="adminUserForm" property="box" >
<logic:iterate id="value" name="adminUserForm" property="box">
<tr>
<td>
<html:multibox property="checkedBox"><bean:write name="value"/></html:multibox>
<bean:write name="value"/>
</td>
</tr>
</logic:iterate>
</logic:notEmpty>
</logic:present> |
Les cases ne sont pas cochées, je ne comprends vraiment pas.
Merci de votre aide.