Bonjour,

Je travaille sur une appli flex (basée sur la dashboard à cette adresse : http://www.adobe.com/devnet/flex/sam...dashboard.html), qui présente des graphiques (pods) qui se basent sur des fichiers xml comme source de données. A chaque fois que mon appli est rafraichie dans mon navigateur (F5 !), une fonction PHP est appelée (via rpc) et met à jour les fichiers xml des graphiques.

Le problème est que ces graphiques ne mettent pas à jour leur données avec les nouveaux xml, mais prennent toujours en compte les anciens. Même si je ferme le navigateur et relance l'appli, les données dans les pods ne sont pas actualisées. On dirait qu'il existe un "cache" qui prend en compte les données uniquement lors du premier lancement.

La seule solution que j'ai trouvée actuellement pour mettre à jour les données et de regénérer et déployer l'appli (release build) dans Flex editor...

Si vous avez des idées, elles seront grandement appréciées

Ci-dessous, le code de mon main.mxml :
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
 
<?xml version="1.0" encoding="utf-8"?>
<!--
 The main application file for the Dashboard demo app.
 Loads the layout XML and creates PodLayoutManagers.
-->
<mx:Application
	xmlns:mx="http://www.adobe.com/2006/mxml"
	horizontalAlign="left"
	minWidth="600" minHeight="600"
	width="100%" height="100%"
	backgroundSize="100%"
	backgroundColor="#ffffff"
	paddingLeft="45" paddingRight="45" paddingBottom="35" paddingTop="34"
	applicationComplete="onApplicationComplete()">
 
	<mx:RemoteObject id="services" destination="amfphp" source="GenerateXML">
	<mx:method name="generate"                
               fault="faultHandler(event)"/>
	</mx:RemoteObject>
 
	<mx:Style source="/assets/styles.css" />
	<mx:Script>
		<![CDATA[
			import com.esria.samples.dashboard.view.DataGridContent;
			import mx.controls.DataGrid;
			import com.esria.samples.dashboard.events.LayoutChangeEvent;
			import com.esria.samples.dashboard.managers.PodLayoutManager;
			import com.esria.samples.dashboard.managers.StateManager;
			import com.esria.samples.dashboard.view.ChartContent;
			import com.esria.samples.dashboard.view.FormContent;
			import com.esria.samples.dashboard.view.ListContent;
			import com.esria.samples.dashboard.view.PieChartContent;
			import com.esria.samples.dashboard.view.Pod;
			import com.esria.samples.dashboard.view.PodContentBase;
			import mx.containers.Canvas;
			import mx.controls.Alert;
			import mx.events.FlexEvent;
			import mx.events.IndexChangedEvent;
			import mx.events.ItemClickEvent;
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;
			import mx.rpc.http.HTTPService;
 
			//----------<RPC PHP>-----------
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;
			import mx.controls.Alert;	
 
			 /**
		     * handleFault
		     * Si erreur, on l'affiche
		     */
		     private function faultHandler(fault:FaultEvent):void
		     {
		          Alert.show(fault.fault.faultString, fault.fault.faultCode.toString());
		     }
 
		     /**
		     * generate
		     * Appel de la methode generate de notre classe PHP
		     */
		     public function generate() :void
		     {
		          services.getOperation('generate').send();
		     }
		     //----------</RPC PHP>-----------	
 
			// Array of PodLayoutManagers
			private var podLayoutManagers:Array = new Array();
 
			// Stores the xml data keyed off of a PodLayoutManager.
			private var podDataDictionary:Dictionary = new Dictionary();
 
			// Stores PodLayoutManagers keyed off of a Pod.
			// Used for podLayoutManager calls after pods have been created for the first time.
			// Also, used for look-ups when saving pod content ViewStack changes.
			private var podHash:Object = new Object();
 
			private function onApplicationComplete():void
			{
				// Load webservice
				generate();
 
				// Load pods.xml, which contains the pod layout.
				var httpService:HTTPService = new HTTPService();
				httpService.url = "data/pods.xml";
				httpService.resultFormat = "e4x";
				httpService.addEventListener(FaultEvent.FAULT, onFaultHttpService);
				httpService.addEventListener(ResultEvent.RESULT, onResultHttpService);
				httpService.send();
			}
 
			private function onFaultHttpService(e:FaultEvent):void
			{
				Alert.show("Unable to load data/pods.xml.");
			}
 
			private function onResultHttpService(e:ResultEvent):void
			{
				var viewXMLList:XMLList = e.result.view;
				var len:Number = viewXMLList.length();
				var containerWindowManagerHash:Object = new Object();
				for (var i:Number = 0; i < len; i++) // Loop through the view nodes.
				{
					// Create a canvas for each view node.
					var canvas:Canvas = new Canvas();
					// PodLayoutManager handles resize and should prevent the need for
					// scroll bars so turn them off so they aren't visible during resizes.
					canvas.horizontalScrollPolicy = "off";
					canvas.verticalScrollPolicy = "off";
					canvas.label = viewXMLList[i].@label;
					canvas.percentWidth = 100;
					canvas.percentHeight = 100;
					viewStack.addChild(canvas);
 
					// Create a manager for each view.
					var manager:PodLayoutManager = new PodLayoutManager();
					manager.container = canvas;
					manager.id = viewXMLList[i].@id;
					manager.addEventListener(LayoutChangeEvent.UPDATE, StateManager.setPodLayout);
					// Store the pod xml data. Used when view is first made visible.					
					podDataDictionary[manager] = viewXMLList[i].pod;
					podLayoutManagers.push(manager);
				}
 
				var index:Number = StateManager.getViewIndex();
				// Make sure the index is not out of range.
				// This can happen if a tab view was saved but then tabs were subsequently removed from the XML.
				index = Math.min(tabBar.numChildren - 1, index);
				onItemClickTabBar(new ItemClickEvent(ItemClickEvent.ITEM_CLICK, false, false, null, index));
				tabBar.selectedIndex = index;
			}
 
			private function onItemClickTabBar(e:ItemClickEvent):void
			{
				var index:Number = e.index;
				StateManager.setViewIndex(index); // Save the view index.
 
				viewStack.selectedIndex = index;
 
				// If data exists then add the pods. After the pods have been added the data is cleared.
				var podLayoutManager:PodLayoutManager = podLayoutManagers[index];
				if (podDataDictionary[podLayoutManager] != null)
					addPods(podLayoutManagers[index]);
			}
 
			// Adds the pods to a view.
			private function addPods(manager:PodLayoutManager):void
			{
				// Loop through the pod nodes for each view node.
				var podXMLList:XMLList = podDataDictionary[manager];
				var podLen:Number = podXMLList.length();
				var unsavedPodCount:Number = 0;
				for (var j:Number = 0; j < podLen; j++)
				{
					// Figure out which type of pod content to use.
					var podContent:PodContentBase = null;
					if (podXMLList[j].@type == "chart")
						podContent = new ChartContent();
					else if (podXMLList[j].@type == "form")
						podContent = new FormContent();
					else if (podXMLList[j].@type == "list")
						podContent = new ListContent();
					else if (podXMLList[j].@type == "pieChart")
						podContent = new PieChartContent();
					else if (podXMLList[j].@type == "dataGrid")
						podContent = new DataGridContent();
 
					if (podContent != null)
					{
						var viewId:String = manager.id;
						var podId:String = podXMLList[j].@id;
 
						// Get the saved value for the pod content viewStack.
						if (StateManager.getPodViewIndex(viewId, podId) != -1)
							podXMLList[j].@selectedViewIndex = StateManager.getPodViewIndex(viewId, podId);
 
						podContent.properties = podXMLList[j];
						var pod:Pod = new Pod();
						pod.id = podId;
						pod.title = podXMLList[j].@title;
						pod.addChild(podContent);
						var index:Number;
 
						if (StateManager.isPodMinimized(viewId, podId))
						{
							index = StateManager.getMinimizedPodIndex(viewId, podId);
							manager.addMinimizedItemAt(pod, index);
						}
						else
						{
							index = StateManager.getPodIndex(viewId, podId);
 
							// If the index hasn't been saved move the pod to the last position.
							if (index == -1)
							{
								index = podLen + unsavedPodCount;
								unsavedPodCount += 1;
							}
 
							manager.addItemAt(pod, index, StateManager.isPodMaximized(viewId, podId));
						}
 
						pod.addEventListener(IndexChangedEvent.CHANGE, onChangePodView);
 
						podHash[pod] = manager;
					}
				}
 
				// Delete the saved data.
				delete podDataDictionary[manager];
 
				// Listen for the last pod to complete so the layout from the ContainerWindowManager is done correctly. 
				pod.addEventListener(FlexEvent.UPDATE_COMPLETE, onCreationCompletePod);
			}
 
			// Pod has been created so update the respective PodLayoutManager.
			private function onCreationCompletePod(e:FlexEvent):void
			{
				e.currentTarget.removeEventListener(FlexEvent.UPDATE_COMPLETE, onCreationCompletePod);
				var manager:PodLayoutManager = PodLayoutManager(podHash[e.currentTarget]);
				manager.removeNullItems();
				manager.updateLayout(false);
			}
 
			// Saves the pod content ViewStack state.
			private function onChangePodView(e:IndexChangedEvent):void
			{
				var pod:Pod = Pod(e.currentTarget);
				var viewId:String = PodLayoutManager(podHash[pod]).id;
				StateManager.setPodViewIndex(viewId, pod.id, e.newIndex);
			}
		]]>
	</mx:Script>
	<mx:Label text="Auto reload toutes les 120 secondes" enabled="true" styleName="podTitle"/>
	<mx:TabBar
		id="tabBar"
		itemClick="onItemClickTabBar(event)"
		height="35" 
		dataProvider="viewStack" />
	<mx:ViewStack
		id="viewStack"
		paddingTop="15"
		width="100%" height="100%" />
</mx:Application>