Un FormAction contient l'attribut :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
// objet contenant le fichier uploadé
private FormFile fichier;
Cet attribut est renseigné via la validation une page JSP (nommée A) : le fichier correspondant contient des engins (objets complexes).

Puis grâce à une Action (nommée Action A), je lis le fichier et affiche le nom des engins contenus dans le fichier via une deuxième JSP (nommée B).

Dans la JSP (nommée B), l'utilisateur sélectionne ou pas les noms des engins qu'il désire récupérer.

Après validation du formulaire, une action (nommée Action B) doit insérer dans la base les engins contenus dans le fichier initiale et dont le nom ont été précédemment sélectionnés.

Mais soucis est donc de pouvoir récupérer le contenu du fichier dans l'action nommée Action B et donc de conserver le FormFile entre l'action A et l'action B.

Comment faire cela ?

Voici le JSP nommée B :

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
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<%@ page language="java"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-html-el" prefix="html-el"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>

<%@ taglib uri="/tags/jstl-c" prefix="c"%>
<html-el:xhtml />

<%@ page import="global.Global"%>

<h1><bean:message key="Exporter-engins" /></h1>

<p class="messageImportant"><html-el:errors
    property="ATT_ERREUR_GLOBAL" /></p>

<html-el:form action="/enginImporter.do" enctype="multipart/form-data">


    <p class="texteCentre">
    <br />
    <strong>
        <bean:message key="Selectionner-types-engins-exporter" />
    </strong>
    </p>

    <nested:file property="fichier" value="fichier"/>
    
    <table class="liste" cellpadding="10" cellspacing="10">
        <tr>
                <th>
                    <bean:message key="Engin" />
                </th>
                
                <th>
                    <span class="separateurDroite">
                        <bean:message key="Selection" />
                    </span>
                    
                <img
                        src="<%=Global.WEB_REP_STYLE_IMAGES + Global.WEB_SEPARATOR%>selection.png"
                        class="vignette"
                        title="<bean:message key="Tout-selectionner"/>"
                        alt="<bean:message key="Tout-selectionner"/>"
                        onclick="return selectAllCheckbox(true);">
                
                <img
                        src="<%=Global.WEB_REP_STYLE_IMAGES + Global.WEB_SEPARATOR%>deselection.png"
                        class="vignette"
                        title="<bean:message key="Ne-rien-selectionner"/>"
                        alt="<bean:message key="Ne-rien-selectionner"/>"
                        onclick="return selectAllCheckbox(false);">
                    
                </th>
        </tr>
        
        <nested:iterate id="engin" name="EnginImporterForm"
            property="listeEngin" indexId="index">
            
            <tr class="ligne<%=index%2%>">
                <td>
                    <nested:write property="nom" />
                    
                    <nested:hidden property="id" />
                </td>
                
                <td>
                    <nested:checkbox property="okP"/>
                </td>
            </tr>
        </nested:iterate>
        
        <tr>
        
            <td colspan="2">
                <input type='image'
                        src="<%=Global.WEB_REP_STYLE_IMAGES + Global.WEB_SEPARATOR%>checkin.png"
                        class="bouton positionnerDroite"
                        title="<bean:message key="Valider"/>"
                        alt="<bean:message key="Valider"/>" />
            </td>
        
        </tr>

            
    </table>
    

</html-el:form>
Mais la balise nested:file ne fait pas du tout cela.


Merci.