Je dois ajouter une case à cocher dans une appli existante. Le problème, c'est qu'un DynaActionForm est utilisé pour cette page. Je ne peut donc pas faire de reset des cases à cocher. J'ai donc créé un nouveau formulaire avec un reset. Quand je valide ce formulaire, j'ai l'erreur suivante (le formulaire n'est pas récupéré semble-t-il) :
javax.servlet.ServletException: BeanUtils.populate
...
java.lang.NullPointerException
at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:515)
JSP :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
<logic:iterate id="applications" name="creerServiceApplicationForm" property="applications">									<tr>
  <td class="texte"><bean:write name="applications" property="appSigle"/></td>
  <td><html:text name="applications" property="code" indexed="true" maxlength="20" size="20" /></td>
  <td><html:checkbox name="applications" property="integ" disabled="false" indexed="true" value="1"/></td>
</tr>
</logic:iterate>
Qui donne en HTML :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
<tr><td class="texte">GESTIONS</td>
  <td><input type="text" name="applications[0].code" maxlength="20" size="20" value="azerty"></td>
  <td><input type="checkbox" name="applications[0].integ" value="1" checked="checked"></td>
</tr><tr>
  <td class="texte">SIGMA</td>
  <td><input type="text" name="applications[1].code" maxlength="20" size="20" value=""></td>
  <td><input type="checkbox" name="applications[1].integ" value="1"></td>
</tr>
Le Form :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class CreationApplicationForm extends ValidatorForm {
  private ApplicationService[] applications;
  public final void reset(ActionMapping mapping, HttpServletRequest request)  {
    System.out.println("*** *** CreationApplicationForm ==> reset");
    if (applications != null) {
		    for (int i = 0; i < applications.length; i++) {
		        ApplicationService appService = (ApplicationService) applications[i];
		        appService.setInteg(null);
		    }
		}
    System.out.println("*** *** CreationApplicationForm ==> fin reset");
  }
  public ApplicationService[] getApplications() {
    System.out.println("*** *** getApplications : " + applications);
    return applications;
  }
... }
struts-config.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
    <form-bean name="creationApplicationForm" 
      type="domaine.struts.form.CreationApplicationForm">
      <form-property name="applications" type="domaine.util.ApplicationService[]"/>
    </form-bean>
    <action
      path="/mettreAJourServiceApplication"
      type="domaine.struts.action.MettreAJourServiceApplicationAction"
      name="creationApplicationForm"
      attribute="creationApplicationForm"
      scope="request"
      unknown="false">
      <forward
        name="success"
        path="/chargerServiceApplication.do"
        redirect="false"
        contextRelative="false" />
    </action>
StdOut après avoir validé le formulaire :
*** *** CreationApplicationForm ==> reset
*** *** CreationApplicationForm ==> fin reset
*** *** getApplications : null