1 Reply Latest reply: Jun 25, 2013 7:22 AM by TucsonJava RSS

    Remote Call to Blazeds and displaying the result set in grid

    Manas66

      Hi,

       

      I want to call a remote method using Flex application from Blazeds and display the values in DataGrid. Can anyone help in this ?

       

      -- I am using AMFChannel

      -- The method to be called is PolicyApnVO.getPoliciesApn()

      -- Please advice any correction if required

       

      Here is the mxml code :

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

                      creationComplete="initApp()" viewSourceURL="srcview/index.html">

         

          <!--

          Simple client to demonstrate runtime configuration of destinations.

          The "runtime-employee" destination is configured in

          EmployeeRuntimeRemotingDestination.java.

          -->

         

          <mx:Script>

              <![CDATA[

                 

                  import mx.messaging.ChannelSet;

                  import mx.messaging.channels.AMFChannel;

                  import mx.rpc.remoting.mxml.RemoteObject;

                 

                  [Bindable]

                  public var srv:RemoteObject;

                 

                  public function initApp():void

                  {

                      var channel:AMFChannel = new AMFChannel("my-amf", "http://192.168.102.208:8400/policyAnalytics/messagebroker/amf");

                      var channelSet:ChannelSet = new ChannelSet();

                      channelSet.addChannel(channel);

                      srv = new RemoteObject();

                      srv.destination="runtime-policy";   

                      srv.channelSet = channelSet;

                      srv.PolicyApnVO.getPoliciesApn();

                  }

                 

              ]]>

          </mx:Script>

         

          <mx:Panel title="Policy Details" width="100%" height="100%">

              <mx:DataGrid width="100%" height="100%" dataProvider="{srv.PolicyApnVO.getPoliciesApn.lastResult.data.result}"

                           showDataTips="true">

                  <mx:columns>

                      <mx:DataGridColumn headerText="APN Id" dataField="apnId"/>

                      <mx:DataGridColumn headerText="APN Name" dataField="apnName"/>

                      <mx:DataGridColumn headerText="Policy ID" dataField="policyId"/>

                      <mx:DataGridColumn headerText="Policy Name" dataField="policyName"/>

                  </mx:columns>

              </mx:DataGrid>

          </mx:Panel>

         

      </mx:Application>

        • 1. Re: Remote Call to Blazeds and displaying the result set in grid
          TucsonJava Community Member

          There may be other ways to do this but here's what I would do:

           

          1) add a results method to the remote object:

          src.result="onResult(event.result)";

           

          2) add the callback method: private function onResult(event : * = null)

          :void{

                                                               if(event is

          ArrayCollection)

                                                                      myData =

          ArrayCollection(event);

                                                        }

           

          3) add the variable: private var myData:ArrayCollection;

           

          4) make the dataProvider for the grid use the my data :

          dataProvider=""

           

          You can probably avoid all this by adjusting your dataProvider. I am just

          not sure what it would be without experimenting. But definitely not what

          you have. Maybe just {svc.result}.