Bonjour j'utilise l'interface ModelDriven dans mon application struts2. J'ai un problème au rendu de mes pages contenant des listes déroulantes j'obtiens l'erreur suivante :
Je ne sais pas comment résoudre cela donc si quelqu’un pouvait m'aider cela serai génial...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 19 nov. 2013 11:23:12 org.apache.catalina.core.StandardWrapperValve invoke GRAVE: "Servlet.service()" pour la servlet jsp a généré une exception tag 'select', field 'list': The requested list key 'listeItems' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location] at org.apache.struts2.components.Component.fieldError(Component.java:240) at org.apache.struts2.components.Component.findValue(Component.java:333) at org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:80)
MyAction.java
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 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.devMode" value="false" /> <constant name="struts.action.extension" value="do" /> <constant name="struts.custom.i18n.resources" value="com.omb.i18n.StrutsResourceBundle" /> <constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" /> <constant name="struts.objectFactory.spring.autoWire" value="name" /> <constant name="struts.i18n.encoding" value="ISO-8859-1" /> <constant name="struts.i18n.reload" value="false" /> <constant name="struts.configuration.xml.reload" value="false" /> <constant name="struts.locale" value="fr" /> <constant name="struts.multipart.maxSize" value="100000000000" /> <constant name="struts.enable.SlashesInActionNames" value="true" /> <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/> <constant name="struts.codebehind.classSuffix" value="Controller"/> <constant name="struts.codebehind.action.checkImplementsAction" value="false"/> <constant name="struts.codebehind.action.checkAnnotation" value="false"/> <constant name="struts.codebehind.action.defaultMethodName" value="index"/> <constant name="struts.configuration.classpath.defaultParentPackage" value="rest-default" /> <package name="default" extends="tiles-default" namespace="/"> <interceptors> <interceptor name="params-filter" class="com.opensymphony.xwork2.interceptor.ParameterFilterInterceptor" /> <interceptor-stack name="defaultStack"> <interceptor-ref name="exception" /> <interceptor-ref name="alias" /> <interceptor-ref name="servletConfig" /> <interceptor-ref name="i18n" /> <interceptor-ref name="chain" /> <interceptor-ref name="modelDriven" /> <interceptor-ref name="fileUpload"> <param name="maximumSize">11204928</param> </interceptor-ref> <interceptor-ref name="staticParams" /> <interceptor-ref name="conversionError" /> <interceptor-ref name="params" /> <interceptor-ref name="prepare" /> <interceptor-ref name="basicStack"/> <interceptor-ref name="validation" /> <interceptor-ref name="workflow" /> </interceptor-stack> </interceptors> <default-interceptor-ref name="defaultStack" /> <global-results> <result name="technicalError" type="chain"> errorAction </result> <result name="sessionInvalidError" type="tiles"> sessionInvalid </result> <result name="blank" type="tiles">blank</result> </global-results> <global-exception-mappings> <exception-mapping exception="java.lang.Exception" result="technicalError" /> <exception-mapping exception="com.omb.service.exception.UserSessionInvalidException" result="sessionInvalidError" /> </global-exception-mappings> </package> <package name="omb" extends="default" namespace="/omb"> <action name="doAction" class="myAction" method="{1}"> <result name="success" type="redirectAction"> <param name="namespace">/omb</param> <param name="actionName">displayResult</param> </result> <result name="error" type="redirectAction"> <param name="namespace">/error</param> <param name="actionName">displayError</param> </result> </action> </package> </struts>
Item.java
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 package com.omb.actions; public class MyAction extends ActionSupport implements ModelDriven<MyModel>{ private MyModel myModel = new MyModel(); public MyModel getModel() { return myModel; } public String execute() throws Exception { myModel.add(new Item("A", "Item A")); myModel.add(new Item("B", "Item B")); return SUCCESS; } public MyModel getMyModel() { return this.myModel; } public void setMyModel(MyModel myModel) { this.myModel = myModel; } }
JSP :
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 package com.omb.modele; import java.util.ArrayList; import java.util.List; import com.omb.item.Item; public class MyModel { private String idItem; private List<Item> listeItems = new ArrayList<Item>(); public String getIdItem() { return this.idItem; } public void setIdItem(String idItem) { this.idItem = idItem; } public List<Item> getListeItems() { return this.listeItems; } public void setListeItems(List<Item> listeItems) { this.listeItems = listeItems; } }
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 <%@ taglib prefix="s" uri="/struts-tags"%> <table width="100%"> <tr> <td><label><s:property value="%{getText('label')}" /></label></td> </tr> <tr> <td><s:select id="idSelectItem" emptyOption="true" list="listeItems" value="idItem" listKey="id" listValue="label" /> </td> </tr> </table>
Partager