sfletcher1959
asked on
Popup Window not executing creationComplete="initApp()"
I have a popup window that only executes creationComplete="initApp( )" the first time the popup is called. When the popup is closed and opened again the creationComplete="initApp( )" doesn't run again.
I need to force "initApp()" to run each time the popup is opened in order to get data via an HTTPService.
Thanks!
I need to force "initApp()" to run each time the popup is opened in order to get data via an HTTPService.
Thanks!
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
dropShadowEnabled="true" shadowDistance="10"
borderStyle="solid" width="540" height="100%"
creationComplete="initApp()" layout="vertical" title="Chart Filters">
<!--
PROGRAM NAME ViewFilters
Purpose: Called from the ChartDesigner Form. Allows Adding / Editing of Filters
-->
<mx:Script>
<![CDATA[
import mx.rpc.http.HTTPService;
import mx.managers.PopUpManager;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import util.ModelLocator;
[Bindable]
private var dataCollection2:XMLList;
[Bindable]
public var model:ModelLocator = ModelLocator.getInstance();
public function initApp():void
{
getChartFiltersService.send() //get the data now
}
private function getResult(event:ResultEvent):void
{
var result:XML = event.result as XML;
dataCollection2 = result..filter as XMLList;
updateGrid();
}
public function updateGrid():void
{
ta3.text = dgFilters.dataProvider.getItemAt(0).fvalue;
}
private function handleCancel() : void {
mx.managers.PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
<mx:HTTPService id="getChartFiltersService"
url="http://localhost/Magic94Scripts/mgrqispi94.dll"
method="POST"
useProxy="false"
resultFormat="e4x"
result="getResult(event)">
<mx:request>
<appname>Web_Dev_Procurement</appname>
<prgname>getFilters</prgname>
<arguments>param1,param2</arguments>
<param1>{model.currentChartId}</param1>
</mx:request>
</mx:HTTPService>
<mx:DataGrid id="dgFilters"
dataProvider="{dataCollection2}" width="100%">
<mx:columns>
<mx:DataGridColumn dataField="ffield" headerText="Field" width="60" />
<mx:DataGridColumn dataField="ftype" headerText="Filter Type" width="40" />
</mx:columns>
</mx:DataGrid>
<mx:TextArea id="ta3" text="{dgFilters.selectedItem.fvalue}" editable="false" width="100%" height="88" />
<mx:TextArea text="{model.currentChartId}"/>
<mx:ControlBar id="controlbar1" horizontalAlign="right" verticalAlign="bottom">
<mx:Button id="searchButton" label="Cancel" click="handleCancel()"/>
</mx:ControlBar>
</mx:Panel>
ASKER
here you go:
// FOLLOWING IS THE FILTER POPUP FORM
private var filter : ViewFilters = new ViewFilters;
// USER SELECTED TO VIEW (EDIT) THE CHART FILTERS
private function handleViewFilters() : void {
if (dG1.selectedIndex == -1) return; //user needs to select a chart before viewing Filters
mx.managers.PopUpManager.a ddPopUp(fi lter,this, true);
mx.managers.PopUpManager.c enterPopUp (filter);
with (filter) {
chartID = dG1.selectedItem.Id;
}
]]>
</mx:Script>
// FOLLOWING IS THE FILTER POPUP FORM
private var filter : ViewFilters = new ViewFilters;
// USER SELECTED TO VIEW (EDIT) THE CHART FILTERS
private function handleViewFilters() : void {
if (dG1.selectedIndex == -1) return; //user needs to select a chart before viewing Filters
mx.managers.PopUpManager.a
mx.managers.PopUpManager.c
with (filter) {
chartID = dG1.selectedItem.Id;
}
]]>
</mx:Script>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Would the better route be to switch from calling a popup to calling a custom component with a viewstack or state?
Thanks!
Thanks!
Explanation:
Calling
>> mx.managers.PopUpManager.r emovePopUp (filter);
makes your filter disappear, but doesn't "delete" it.
Next time you call
>> mx.managers.PopUpManager.a ddPopUp(fi lter,this, true);
**the same filter** is shown again.
By calling resetFilter() after PopUpManager.removePopUp(f ilter);
you are assured that the next time you do
>> mx.managers.PopUpManager.a ddPopUp(fi lter, this, true);
a NEWLY CREATED filter is shown
Calling
>> mx.managers.PopUpManager.r
makes your filter disappear, but doesn't "delete" it.
Next time you call
>> mx.managers.PopUpManager.a
**the same filter** is shown again.
By calling resetFilter() after PopUpManager.removePopUp(f
you are assured that the next time you do
>> mx.managers.PopUpManager.a
a NEWLY CREATED filter is shown
>> Would the better route be to switch from calling a popup to calling a custom component with a viewstack or state?
In my opinion that popup is OK. As long as you make sure - e.g. by using the code I posted - its content is up-to-date
In my opinion that popup is OK. As long as you make sure - e.g. by using the code I posted - its content is up-to-date
ASKER
I got the syntax wrong because I get "undefined method resetFilter" error.
private function handleCancel() : void {
mx.managers.PopUpManager.r emovePopUp (this);
resetFilter();
}
Sorry, I am new to Flex.
private function handleCancel() : void {
mx.managers.PopUpManager.r
resetFilter();
}
Sorry, I am new to Flex.
ASKER
sorry your post #285 just appeared --- I see
ASKER
Ok, I am still having the error in the viewFilters.mxml - "call to possibly undefined method resetFilter".
Does the following belong in the ChartDesigner.mxml (where the popup is called from) or in the viewFilters.mxml (the popup itself)?
Does the following belong in the ChartDesigner.mxml (where the popup is called from) or in the viewFilters.mxml (the popup itself)?
private function get filter():ViewFilters {
if (_filter==null) {
_filter = new ViewFilters();
}
return _filter;
}
private function resetFilter():void {
_filter = null;
}
ASKER
I had to move some things around until I found what when where. But this was the solution and it works great
Thanx 4 axxepting
That's because the popup panel is not recreated. It is simply removed by the popup manager but it still exists invisibly.
When it pops up again it is NOT recreated and hence the creationComplete event is not thrown.
Show me your code where you make the panel pop up.