Search code examples
javajspstruts

Struts forms still empty


I am beginner developer and i'm working on a web application in Java whith struts. I have a problem with my struts form which stay empty after user enters informations. I've tried many way to resolve it but nothing worked. Maybe the code lines will help you to help me ;). My Jsp page :

<tr>
<td colspan="5">
    <div class="content" align="center">
        <form action="statistiques.do" method="POST">
            <input type="hidden" name="operation" value="module1">
            <tr>
                <td><font size="3">&Eacute;tat&nbsp;:&nbsp;</td>
                <td>
                    <select name="choixEtat">
                        <option value='1' selected>Tous</option>
                        <option value='2' >Actif</option>
                        <option value='3' >Inactif</option>
                    </select>
                </td>   
            </tr>   
            <tr>
                <td>Date de d&eacute;but&nbsp;:<span style="font-weight: bolder; color: red;">&nbsp;&#42;</span></td>
                <td>
                    <input type="text" name="dateDebut" size="10" maxlength="10" id="date" value="" 
                           required="required">
                </td>
            </tr>
            <tr>
                <td>Date de fin&nbsp;:<span style="font-weight: bolder; color: red;">&nbsp;&#42;</span></td>
                <td>
                    <input type="text" name="dateFin" size="10" maxlength="10" id="date2" value="" 
                           required="required">
                </td>
            </tr>

            <tr>
                <td><font size="3">Charg&eacute;(e)(s)</td>
                <td>
                    <select name="chargeMatricule">
                        <option value="0" selected></option>
                        <% for (Utilisateur u : utilisateurs) {%>
                        <option value="<%=u.getUtilisateurMatricule()%>"><%=u.getUtilisateurNom() + ", " + u.getUtilisateurPrenom()%></option>
                        <%}%>
                    </select>
                </td>
            </tr>
            <tr>
                <td><font size="3">Activit&eacute;&nbsp;:&nbsp;</td>
                <td>
                    <select name="activiteNom">
                        <option value="0" selected></option>
                        <% for (String s : activites) {%>
                        <option value="<%=s%>"><%=s%></option>
                        <%}%>
                    </select>
                </td>
            </tr>
            <td colspan='5' align="center">
                <input type="submit">
            </td>
            </tr>
        </form>
    </div>
</td>

and my action :

public class ActionStatistiques extends DispatchAction {

public ActionForward module1(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    FormStatMod1 forms = (FormStatMod1) form;
    ServiceStatistiques service = new ServiceStatistiques();
    String dd = forms.getDateDebut();
    String dateDebut = dd.substring(6, 10) + '-' + dd.substring(3, 5) + '-' + dd.substring(0, 2);
    String df = forms.getDateFin();
    String dateFin = df.substring(6, 10) + '-' + df.substring(3, 5) + '-' + df.substring(0, 2);
    Collection[] collections = service.module1(forms.getChoixEtat(), dateDebut, dateFin);
    Collection<Flux> listef = collections[1];
    String activiteNom = forms.getActiviteNom();
    String chargeMatricule = forms.getChargeMatricule();

Hope, someone will see what's wrong. Have a nice day!!


Solution

  • Ok i found my way!!! Like many times it was a stupid omission ... a setter missed in my form!!! Never will forget to check it.