Bonjour,
je suis entraine de développer une application Web et j'utilise Struts. je voudrais cree deux liste déroulante dans le contenu de la deuxième et dépend de la 1 ere, mais je bloque sur ce point. j'ai essayé de faire :
et dans la classe action je fait ca :
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 <jsp:useBean id="listCountrySiteBean" scope="session" class="com.atosorigin.ssc.portal.treatment.ListeCountrySite"/> <jsp:useBean id="listTemplateBean" scope="session" class="com.atosorigin.ssc.portal.treatment.ListTemplateProjectReq"/> <%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %> <script type="text/javascript"> function submitChange ( ){ // --- Modification du parametre action qui va permettre d'appeller la bonne méthode JAVA a éxécuter. document.forms[0].action.value = 'change'; // --- Soumission du formulaire. document.forms[0].submit; } </script> <body> <%@ include file="header.jsp" %> <table class="mainlayout"> <tr height=467> <td bgcolor='#F0F0F0' WIDTH=200 valign="bottom"></td> <td width=2></td> <td WIDTH=890 valign="top"> <div class='logo' > <img src="<%=request.getContextPath()%>/images/logosscmiddle.png" alt='Atos Origin' title='Atos Origin'/> </div> <table class="columnsFlow"> <tr> <td><br> <h2>Create Project REQPro</h2> <table> <html:form action="/actionCreatProjectReqPro"> <tr> <td width=50>Country Name</td> <td> <html:select property="pays" onchange="javascript:submitChange()"> <html:options name="listCountrySiteBean" property = "listCountry"/> </html:select> </td> </tr> <tr> <td width=50>Site Name</td> <td> <html:select property="region"> <html:options name="listSite"/> </html:select> </td> </tr> <tr> <td width=50>Template Name</td> <td> <html:select property="template"> <html:options name ="listTemplateBean" property ="listeTemplate"/> </html:select> </td> </tr> <tr> <td width=50>Client Name</td> <td><html:text property="clinetName"/> </td> </tr> <tr> <td width=50>Project name</td> <td><html:text property="projectName"/> </td> </tr> <tr> <td align="center"><html:submit/> </td> </html:form> </table> </td> </tr> </table> </td> </tr> </table> <%@ include file="footer.jsp" %> </body> </html>
mais ça marche pas du tout j'arrive à afficher que la première liste. est ce que vous avez une piste SVP c'est très urgent
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 public ActionForward change (final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response){ ActionForward forward = new ActionForward(); //test of creatProjectReqProForm ArrayList<String> listSite = new ArrayList<String>(); if (request.getParameter("pays") != null){ listSite.add("aa"); listSite.add("bb"); listSite.add("cc"); request.setAttribute("listSite", listSite); forward = mapping.findForward(ActionForwardConstants.FORWARD_ACTION_CONF); } else { listSite.add("--chose a site --"); request.setAttribute("listSite", listSite); forward = mapping.findForward(ActionForwardConstants.FORWARD_ACTION_CONF); } return forward; }
Partager