clear flex cache/memory data

hi guys

Is there a way to clear cahce/memory data in flex?
i have something like

<mx:ViewStack id="mainViewStack" width="100%" height="100%" >
<mx:HBox id="homePage" borderStyle="" paddingLeft="60" paddingTop="20" >   ---tab 1
<view:projectView id="workflowPage" width="100%" />
</mx:HBox>
                  
 <mx:VBox id="usersPage" paddingLeft="60" paddingTop="40">                ---tab 2
<mx:Label text="The Users page... for now..."/>                         </mx:VBox>
                  
<mx:VBox id="reportsPage" paddingLeft="60" paddingTop="40">              ---tab 3
<mx:Label text="The report page... for now..."/>                         </mx:VBox>
</mx:ViewStack>

when user clicks on tab1 my code makes a database call and gets the results.
when user clicks on tab 2 and then clicks again on tab 1, its not making a
database call again. its getting the data from the cache/memory of tab1. Is there a way i can avoid that?

My requirment is that everytime when tab1 is clicked it should get the latest values from the database.
any ideas?

thanks.

thanks
royjaydAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dgofmanCommented:
Check childrenPolicy or chilPolicy  propery in your ViewStack you have to use None.
I will verofy if you will not find yourself
0
dgofmanCommented:
I think its calls createPolicy and availabel for all Container classes by default is auto u need to change to none
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

royjaydAuthor Commented:
ok
tried createpolicy=null but no  luck
here is my entire code
main.mxml  -- the first mxml which is called

main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"  
xmlns:comp="comp.flexlib.controls.*"      
xmlns:view="com.view.*"      
xmlns:projectWork="com.view.projectWork.*"
creationComplete="init()"  backgroundGradientAlphas="[1.0, 1.0]"
backgroundGradientColors="[#FFFFFF, #DDDDDD]"  xmlns:layout="flexlib.layout.*">
<mx:Style source="style/comp.css"/>
<mx:XML id="menus" source="data/nav.xml"  format="e4x" />  --menus loaded from this xml
<mx:Script>
<![CDATA[
import com.flexspy.FlexSpy;      
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;                  
import comp.BannerEvent;
public function init():void {                  
banner.addEventListener("HomeScreenEvent", bannerListner);       -- tab1            
banner.addEventListener("UserScreenEvent", bannerListner);       -- tab2banner.addEventListener("ReportScreenEvent", bannerListner);       -- tab3banner.logo="logoCompany";      
}
                  
public function bannerListner(event:BannerEvent):void {
switch(event.type)
{
case "HomeScreenEvent":
mainViewStack.selectedIndex=0;                              
break;      
case "UserScreenEvent" :
mainViewStack.selectedIndex=1;
break;            
case "ReportScreenEvent" :
mainViewStack.selectedIndex=2;
break;
default :
mainViewStack.selectedIndex=1;
break;                  
}
}  
]]>
</mx:Script>      
<mx:VBox width="100%" height="100%" borderStyle="solid">            
<comp:Banner x="0" y="0" id="banner" menuXML="{menus}" logo="logoCompany" bannerType="standard"/>      
<mx:ViewStack id="mainViewStack" width="100%" height="100%" >  The main view stack<mx:HBox id="homePage" borderStyle="" paddingLeft="60" paddingTop="20" >  -- the home page (1st tab)
<view:projWorkMasterView width="100%" />
</mx:HBox>
<mx:VBox id="usersPage" paddingLeft="60" paddingTop="40">                 --second tab      
<mx:Label text="The Users page... for now..."/>                         </mx:VBox>
<mx:VBox id="reportsPage" paddingLeft="60" paddingTop="40">                -- third tab      
<mx:Label text="The report page... for now..."/>                          </mx:VBox>
</mx:ViewStack>
</mx:VBox>
</mx:Application>

nav.xml is
<?xml version="1.0" encoding="UTF-8"?>
<Banner title="Questionaire" xmlns="http://comp.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://comp./schema/compone.xsd ">
<PrimaryNav>
<PrimaryNavMenuItem label="Home" eventType="HomeScreenEvent" />      --1st Home tab <PrimaryNavMenuItem label="Users" eventType="UserScreenEvent"/>               --2nd  users tab<PrimaryNavMenuItem label="Reports" eventType="ReportScreenEvent"/>          --3rd Reports tab</PrimaryNav>
</Banner>


and this is my <view:projWorkMasterView>
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" borderColor="#F7F7F7"
      xmlns:projectNav="com.ms.ewq.view.projectNav.*"
      xmlns:projectWork="com.ms.ewq.view.projectWork.*"
      creationComplete="init()" xmlns:project="com.ms.ewq.entity.project.*">
<mx:ViewStack id="projectViewStack" width="100%" >
<projectNav:selectProjectView id="selectView"  includeInLayout="false" height="1700" />  --  this is the first screen under first tab      
<projectWork:projectDashboard id="dashBoardView"   includeInLayout="false" height="1700"  />  --  this is the second screen under first tab      
</mx:ViewStack>
<mx:Script>
<![CDATA[                  
import com.project.ProjectSummaryDTO;
import com.projectNav.ListItemRenderer;                  
import flash.utils.getQualifiedClassName;                  
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.core.Container;
import mx.events.ItemClickEvent;
                  
 public function init():void{}

 public function toggleProjectView(event:MouseEvent):void{
if((projectViewStack.selectedChild as Container).id == "selectView")
{
var selectedProject:ProjectSummaryDTO = this.selectView.projectList.getItemAt(this.selectView.projectListComponent.selectedIndex) as ProjectSummaryDTO;
this.dashBoardView.currentProject = selectedProject;
projectViewStack.selectedChild = this.dashBoardView;
}
else {
Alert.show('inside else','ELSE');
projectViewStack.selectedChild = this.selectView;
}
}
]]>
</mx:Script>
</mx:VBox>


so when ever Home tab is clicked (which is in the nav.xml, it should show the data from <projectNav:selectProjectView> only which is the
first screen under first tab. It should not show me <projectWork:projectDashboard>.

Hope this makes sense.

thanks v much.
0
dgofmanCommented:
I don't see you are implementing creationPolicy.

<mx:ViewStack id="mainViewStack" width="100%" height="100%" creationPolicy="none">

Are you requesting to your data inside each view or from main.xml?

0
royjaydAuthor Commented:
good morning dgofman:
the problem is i tried <mx:ViewStack id="mainViewStack" width="100%" height="100%" creationPolicy="none">

but when i run, i see a blank page ;-(

i am requesting the data from main.mxml

main.mxml  contains a view stack whihc contains tabs

<mx:ViewStack id="mainViewStack" width="100%" height="100%" creationPolicy="none">
<mx:HBox id="homePage" borderStyle="" paddingLeft="60" paddingTop="20" >  tab 1<view:projWorkMasterView width="100%" />
</mx:HBox>
                  
<mx:VBox id="usersPage" paddingLeft="60" paddingTop="40"> tab 2
<mx:Label text="The Users page... for now..."/>                         </mx:VBox>
            
....


and view:projWorkMasterView  contains another viewstack  projectViewStack

<view:projWorkMasterView>
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" borderColor="#F7F7F7"
      xmlns:projectNav="com.ms.ewq.view.projectNav.*"
      xmlns:projectWork="com.ms.ewq.view.projectWork.*"
      creationComplete="init()" xmlns:project="com.ms.ewq.entity.project.*">
<mx:ViewStack id="projectViewStack" width="100%" >
<projectNav:selectProjectView id="selectView"  includeInLayout="false" height="1700" />  <projectWork:projectDashboard id="dashBoardView"   includeInLayout="false" height="1700"  />
</mx:ViewStack>

-- initially selectProjectView is loaded when an item is clicked on selectProjectView screen, projectDashboard screen is loaded.
      
0
royjaydAuthor Commented:
let me post that again, the alignment i not proper

<mx:ViewStack id="mainViewStack" width="100%" height="100%" creationPolicy="none">
<mx:HBox id="homePage" borderStyle="" paddingLeft="60" paddingTop="20" >     tab 1 <view:projWorkMasterView width="100%" />
</mx:HBox>
                   
<mx:VBox id="usersPage" paddingLeft="60" paddingTop="40">                             tab 2
<mx:Label text="The Users page... for now..."/>                    
</mx:VBox>
           
....


and view:projWorkMasterView  contains another viewstack  projectViewStack

<view:projWorkMasterView>
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" borderColor="#F7F7F7"
      xmlns:projectNav="com.ms.ewq.view.projectNav.*"
      xmlns:projectWork="com.ms.ewq.view.projectWork.*"
      creationComplete="init()" xmlns:project="com.ms.ewq.entity.project.*">
<mx:ViewStack id="projectViewStack" width="100%" >
<projectNav:selectProjectView id="selectView"  includeInLayout="false" height="1700" />  <projectWork:projectDashboard id="dashBoardView"   includeInLayout="false" height="1700"  />
</mx:ViewStack>

Initially selectProjectView is loaded which contains the summary information(with summary items)
 When a summary item is clicked, projectDashboard screen is loaded (projectDashboard  contains the detail information).

thx
0
dgofmanCommented:
Look, you have couple options to handle your problem.
1) Implement request to your DataBse from each view.
For example:
In Tab 1 on creationComplete event making request to DB for updating Tab 1 components.
In Tab 2 on creationComplete event making request to DB for updating Tab 2 components, etc.

2) You can create in main.mxml bindable variables for each view and add event for ViewStack for making request to update those variable or pass result data to the selectedChild.

<mx:ViewStack change="updateViewId(event.target.selectedIndex)">
0
royjaydAuthor Commented:
ok thanks
looks like i am getting close to the problem
In main.mxml  i put an alert in the init()

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"  
xmlns:comp="comp.flexlib.controls.*"      
xmlns:view="com.view.*"      
xmlns:projectWork="com.view.projectWork.*"
creationComplete="init()"  backgroundGradientAlphas="[1.0, 1.0]"
backgroundGradientColors="[#FFFFFF, #DDDDDD]"  xmlns:layout="flexlib.layout.*">
<mx:Style source="style/comp.css"/>
<mx:XML id="menus" source="data/nav.xml"  format="e4x" />  --menus loaded from this xml
<mx:Script>
<![CDATA[
import com.flexspy.FlexSpy;      
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;                  
import comp.BannerEvent;
public function init():void {        
    Alert.show("main.mxml", "main");banner.addEventListener("HomeScreenEvent", bannerListner);                  
banner.addEventListener("UserScreenEvent", bannerListner);      
banner.addEventListener("ReportScreenEvent", bannerListner);     tab3banner.logo="logoCompany";      
}

The alert pops up only the first time when screen loads but when the tab is clicked again it never pops.
0
dgofmanCommented:
You are still too far :)

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"
				backgroundGradientAlphas="[1.0, 1.0]" 
				backgroundGradientColors="[#FFFFFF, #DDDDDD]">
	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;

			public function tabChangeHandler(event:Event):void {
				Alert.show("Send DB request for : " + event.target.selectedChild.label, "tabChangeHandler");
			}
		]]>
	</mx:Script>
	<mx:TabNavigator width="100%" height="100%" change="tabChangeHandler(event)" creationComplete="tabChangeHandler(event)">
		<mx:Canvas label="RED" backgroundColor="#ff0000"/>
		<mx:Canvas label="GREEN" backgroundColor="#00ff00"/>
		<mx:Canvas label="BLUE" backgroundColor="#0000ff"/>
	</mx:TabNavigator>
</mx:Application>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
royjaydAuthor Commented:
thanks. you are on the lead now in this forum with points :)
well done. you deserve it for all your work and talent. Thanks for help!

0
royjaydAuthor Commented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Flex

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.