Libby,
 
You wouldn't typically call a method on a servlet through the RemoteObject mechanism. Instead, RemoteObject is there to let you call methods on plain old Java objects (pojos) or EJBs. So to modify your example a bit, if you had a Java class called "ItemDefFacade" (which *doesn't* subclass Servlet) that supported a method with the signature:
 
    public ArrayList getAllRecords()
 
...then you would set up your RemotObject tag like this:
 
<mx:RemoteObject id="remoteObj1" source="maintenance.ItemDefFacade">
    <mx:method name="getAllRecords" result="handleGetAllRecordsResult(event.result)" />
<mx:RemoteObject>
Notice that you have to specify the methods that can be invoked on the remote object and you have to specify a handler to be triggered when each method returns a result (the event.result property contains the actual returned value). In this case we've pointed it to an ActionScript function called handleGetAllRecordsResult() which might look like this:
 
<mx:Script>
<![CDATA[
 
function handleGetAllRecordsResult(recordsList)
{
    myDisplayGrid.dataProvider = recordsList;
}
 
]]>
</mx:Script>
 
 
So to get the whole ball rolling, you need to trigger the method on the remote object. Here is a button that would do just that:
 
<mx:Button click="remoteObj1.getAllRecords()" />
 
You'll find more thorough coverage of this topic in the Flex docs here:
http://livedocs.macromedia.com/flex/15/flex_docs_en/00002244.htm
 
I hope that helps.
 
 
 
Kris
 
--
 
Kristopher Schultz
Developer
 
Resource Interactive
p: 614.410.2123
 


From: Libby [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 24, 2005 2:51 PM
To: [email protected]
Subject: [flexcoders] Calling Java Servlet


Hello,
I am evaluating Flex. We have flash Remoting calling some servlets
running on Websphere 5.1, and for my eval I am trying to build a
similiar interface to them. So far I cannot find an example of how to
do this (call a servlet with arguments) so I was hoping someone here
could show me a tiny example, or offer corrections to my code?

Using flash, we call a controller servlet using one or more arguments.
ItemDefServlet("getAllRecords"); <-- like this in Flash

In Flex, this is what I have:
<mx:RemoteObject type="servlet" source="maintenance.ItemDefServlet"
protocol="http" id="remoteobject1"></mx:RemoteObject>


<mx:DataGrid id="ItemDef_grd"
dataProvider="{remoteobject2.getMessage.result}">
.
.
</mx:DataGrid>
  <mx:ControlBar>
        <mx:Button label="Get All" click="remoteobject1.send()" />
      </mx:ControlBar>
thanks,
Libby



Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to