Skip navigation
Manas66
Currently Being Moderated

Remote Call to Blazeds and displaying the result set in grid

Jun 25, 2013 3:49 AM

Tags: #flex #blazeds #flash_builder_4.7

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>

 
Replies
  • Currently Being Moderated
    Jun 25, 2013 7:22 AM   in reply to Manas66

    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: Re: Remote Call to Blazeds and displaying the result set in grid 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}.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points