0 Replies Latest reply on May 10, 2010 4:36 AM by josgall79

    refresh datagrid when using httpservice/coldfusion serialized data output

    josgall79

      Hi there,

       

      I am working in an environment where all remote objects, web services and xml connections are blocked for security purposes. I am using coldfusion to output serialized data as found at the following link (example at link uses jsp, old link, but same concept):

       

      http://cookbooks.adobe.com/post_Building_Flex_Applications_with_JSPs-7746.html

       

      my cfm page is setup properly I believe, and fills the data grid in my mxml properly upon loading the page initially, with data from my database. However, upon removing a row from the database, and navigating to the page again, the grid still retains the removed row. I'm pretty sure that this is because I need to setup an event listener, but I don't know a lot about them.

       

      How would I set up a listener to basically refresh my data grid any time any action is performed on the page, or if someone navigates away from the page and then back to it again? Currently I can only achieve these results by clearing my browser cache and refreshing the page.

       

      I attempted to use some code I found at the following link to call invalidateList() and invalidateDisplayList() as outlined here, with no success:

       

      http://devharbor.blogspot.com/2008/10/refresh-flex-datagrid.html

       

      I have my flex code setup as follows:

       

      <?xml version="1.0" encoding="utf-8"?>
      
      <mx:Application
      
      
      
      xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init();allavail.send();complete.send();required.send();" color="#FFFFFF" backgroundColor="#FFFFFF" borderStyle="none" backgroundAlpha="0.03" width="568" cornerRadius="2" height="448">
      
      
      
      <mx:Script>
      <![CDATA[
      
      
      public function init():void{ enrollment.invalidateList();
      enrollment.invalidateDisplayList();
      }
      
      
      ]]>
      
      
      </mx:Script> 
      
      <mx:HBox width="436">
      
      
      <mx:Label text="My Training" width="238" color="#C65ECC" fontWeight="bold" fontSize="15"/>
      
      
      <mx:LinkBar dataProvider="{vsMain}" fontWeight="Bold" color="#7C797F" width="174" borderColor="#6002FB"/>
      
      
      </mx:HBox>
      
      <mx:HRule width="440"/>
      
      <mx:HTTPService id="allavail" url="invokeFLEXqueryCFC_ALLAVAILABLE.cfm"/> 
      
      <mx:HTTPService id="complete" url="invokeFLEXqueryCFC_COUNTCOMPLETE.cfm"/> 
      
      <mx:HTTPService id="required" url="invokeFLEXqueryCFC_COUNTREQUIRED.cfm"/> 
      
      <mx:DataGrid dataProvider="{allavail.lastResult.LIST.MODULE}" id="enrollment" color="#8E8D8D" width="458" height="132">
      
      <mx:columns> 
      
      <mx:DataGridColumn headerText="Training Type" width="30" dataField="MODULE_TYPE"/>
      
      <mx:DataGridColumn headerText="Name" width="75" dataField="MODULE_NAME" id="title"/>
      
      <mx:DataGridColumn headerText="Status" width="20" dataField="STATUS"/>
      
      </mx:columns>
      
      </mx:DataGrid>
      
      <mx:HBox width="458" height="70">
      
      <mx:TextArea width="259" height="70" editable="false" enabled="true" text="{enrollment.selectedItem.MODULE_INFO}" color="#000000"/>
      
      <mx:Button label="Enroll/Cancel" color="#858484"/>
      
      </mx:HBox>
      
      <mx:HRule width="440"/>
      
      <mx:Label text="Training Progress" width="457" color="#8C8A8A" fontWeight="bold"/>
      
      <mx:HBox width="450" color="#989696" cornerRadius="0" borderStyle="none">
      
      <mx:Legend dataProvider="{trainingProgress}" width="105" height="80"/>
      
      <mx:BarChart id="trainingProgress" height="83" width="308">
      
      <mx:series>
      
      <mx:BarSeries displayName="Complete" xField="" dataProvider="{required.lastResult.LIST.MODULE.REQUIRED}"/>
      
      <mx:BarSeries displayName="Level" xField="" dataProvider="White"/>
      
      </mx:series>
      
      </mx:BarChart>
      
      </mx:HBox>
      
      <mx:ViewStack id="vsMain">
      
      <mx:Canvas label="White">
      
      </mx:Canvas>
      
      <mx:Canvas label="Red">
      
      </mx:Canvas>
      
      <mx:Canvas label="Blue">
      
      </mx:Canvas>
      
      <mx:Canvas label="Gold">
      
      </mx:Canvas> 
      
      </mx:ViewStack> </mx:Application>
      
      


      and my cfm code is setup like this, with a call to a cfc function which just pulls a query and returns the values back to the cfm for serialized output:

       

      <!----PULL DATA TO FILL TABLES----->
      <cfinvoke
              component="CFC.FLEXquery" 
              method="ALLAVAILABLE" 
              returnVariable="QueryReturned"
      />
      <!---ALLAVAILABLE TRAINING MODULES--->
      <?xml version="1.0" encoding="utf-8"?>
      <LIST>
          <cfloop from="1" to="#QueryReturned.recordcount#" index="i">
              <MODULE MODULE_ID="<cfoutput>#QueryReturned.MODULE_ID[i]#</cfoutput>"> 
                  <MODULE_TYPE><cfoutput>#QueryReturned.MODULE_TYPE[i]#</cfoutput></MODULE_TYPE>
                  <MODULE_NAME><cfoutput>#Replace(QueryReturned.MODULE_NAME[i],"&","&amp;")#</cfoutput></MODULE_NAME>
                  <MODULE_INFO><cfoutput>#Replace(QueryReturned.MODULE_INFO[i],"&","&amp;")#</cfoutput></MODULE_INFO>
                  <PREAPPROVAL><cfoutput>#QueryReturned.PREAPPROVAL[i]#</cfoutput></PREAPPROVAL>
                  <COVERAGE><cfoutput>#QueryReturned.COVERAGE[i]#</cfoutput></COVERAGE>
                  <STATUS><cfoutput>#QueryReturned.STATUS[i]#</cfoutput></STATUS>
              </MODULE>                                       
          </cfloop>
      </LIST>
      


      any help is much appreciated!