2 Replies Latest reply on Jun 3, 2008 10:23 PM by Abrabra

    Refreshing view state

      Hi all,

      I am creating an application with 3 view states, namely: Login, Project Listing, Items related to a project.
      After I login, I am able to see a list of project within a data grid. After selected a project and click on an open button, the application will change state and goto item state where list of items will be display.

      My problem is, 1st time I open a [project->item list] it always work. But when I open another project, it still show me the first project items (unless I add another refresh button). Is there any ways to 'auto-reload' the item list page (creationComplete not working since the component already created)

        • 1. Re: Refreshing view state
          Gregory Lafrance Level 6
          Simple sample code.
          • 2. Refreshing view state
            Abrabra Level 1
            This is my main.mxml

            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" horizontalAlign="center" verticalAlign="middle" xmlns:v="views.dataEntry.*" xmlns:ns1="com.rphelan.controls.*" xmlns:ns2="views.navigation.*" resetHistory="true">
            <mx:RemoteObject id="myservice" source="isms.com.code.LoginService" destination="amfphp" fault="faultHandler(event)" showBusyCursor="true">
            <mx:method name="validate" result="validate(event)" fault="faultHandler(event)">
            <mx:arguments xmlns="">
            <mx:method name="getUser" result="getUser(event)" fault="faultHandler(event)" />
            <mx:method name="logout" fault="faultHandler(event)" />
            <mx:State name="Logged In" enterState="myservice.getOperation('getUser').send();">
            <mx:SetProperty target="{panel1}" name="width" value="95%"/>
            <mx:SetProperty target="{panel1}" name="height" value="95%"/>
            <mx:SetProperty target="{panel1}" name="title" value="ISMS - Main Console"/>
            <mx:RemoveChild target="{username}"/>
            <mx:RemoveChild target="{submit}"/>
            <mx:RemoveChild target="{label1}"/>
            <mx:RemoveChild target="{password}"/>
            <mx:RemoveChild target="{label2}"/>
            <mx:SetStyle target="{panel1}" name="resizeEffect" value="Resize"/>
            <mx:AddChild relativeTo="{panel1}" position="lastChild">
            <v:projectForm horizontalCenter="5" verticalCenter="5" id="projectform1"/>
            <mx:State name="Console" basedOn="Logged In" id="Console">
            <mx:RemoveChild target="{projectform1}"/>
            <mx:SetProperty target="{panel1}" name="title" value="Main Console"/>
            <mx:RemoveChild target="{username}"/>
            <mx:RemoveChild target="{submit}"/>
            <mx:RemoveChild target="{label1}"/>
            <mx:RemoveChild target="{password}"/>
            <mx:RemoveChild target="{label2}"/>
            <mx:AddChild relativeTo="{panel1}" position="lastChild">
            <ns2:mainForm width="100%" height="100%" left="0" top="0">

            This is portion of the project form component(which display list of project that belongs to a user):
            <mx:DataGrid id="dgUserRequest" dataProvider="{dp}" width="560" change="changeHandler(event)">
            <mx:DataGridColumn headerText="ID" dataField="pid" width="50" />
            <mx:DataGridColumn headerText="Project Name" dataField="name"/>
            <mx:DataGridColumn headerText="Description" dataField="description" wordWrap="true"/>
            <mx:DataGridColumn headerText="Modify Date" dataField="modifydate"/>
            <mx:HBox width="561" height="36" horizontalAlign="center" verticalAlign="middle">
            <mx:Button label="Open" width="64" height="22" id="btnOpen" click="changeState();"/>
            <mx:Button label="Delete" width="64" height="22" id="btnDelete"/>

            When user select a project and click open, state change to "console" (which will load item component):

            <mx:DataGrid x="24" y="180" width="424" height="146" id ="setting">
            <mx:DataGridColumn headerText="ID" width="30" dataField="col1"/>
            <mx:DataGridColumn headerText="Rating" dataField="col2"/>
            <mx:DataGridColumn headerText="Description" dataField="col3"/>

            By the way I'm using amfphp for backend process. When I select a project and click open, it will update a session variable project id and change currentState = "console". After that in the creationComplete I call RemoteObject to fill in the datagrid "setting". My problem is when I go back to project and select another project and click open again, the datagrid at item component datagrid still keeps the previous project values. I tried to add an button call refresh to reload the value. It actually do work. Are there any alternative to fill the datagrid with out the refresh button?