Probleme avec le DispatchAction
Bonjour tout L monde,
J'utilise un DispatchAction pour gerer deux actions dans une page jsp je modifie bien mon fichier struts-config en ajoutant le champ parametre comme ceci :
Code:
1 2 3 4 5 6 7 8 9 10 11
|
<action
attribute="modification1Form"
input="/modification1.jsp"
name="modification1Form"
parameter="operation"
path="/modification1"
scope="request"
type="com.iam.struts.action.Modification1Action">
<forward name="tout" path="/modification1.jsp" />
</action> |
Tandis que dans mon Action.class :
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
|
public class Modification1Action extends DispatchAction {
public ActionForward lire(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
Modification1Form modifes = (Modification1Form) form;
Integer anneeSelected=modifes.getAnnee();
modifes.setAnnee(anneeSelected);
modifes.setFinanceList(Charger.chargerList(anneeSelected)) ;
return mapping.findForward("tout");
}
public ActionForward save(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
Modification1Form modifes = (Modification1Form) form;
Integer year=modifes.getAnnee();
ArrayList<Finance> ham =modifes.getFinanceList();
Modifier.modifier(Charger.chargerList(year),ham, year);
return mapping.findForward("tout");
} |
J'ai deux fonctions gérées par le DispatchAction : lire et save .
Et finallement dans la jsp je gère le traitement comme suit :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<SCRIPT>function set(target) {document.Modification1Form[0].operation.value=target;}</SCRIPT>
// Pour la fonction lire via une Liste déroulante
annee : <html:select property="annee" onchange="setHidden('lire');" onchange="submit();">
<html:option value ="2007">2007</html:option>
<html:option value ="2008">2008</html:option>
<html:option value ="2009">2009</html:option>
<html:option value ="2010">2010</html:option>
</html:select>
//La fonction save
<html:submit onclick="set('save');">SAVE</html:submit> |
Le problème se trouve en niveau de la fonction save qui me retourne l'erreur suivante :
'document.Modification1Form.0' a la valeur null ou n'est pas un objet.
L'autre fonction lire marche très bien sans problème.
Votre aide sera la bienvenue.