[flexcoders] Re: Newbie, RemoteObject with ActionScript

2008-03-31 Thread bennybobw
Todd,
Sorry, I think I'm misunderstanding something very basic here. Aren't
both mxml and RO calling the method views.getView(test,
['nid','title','body','changed'])?

The method server side is views.getView(view name (string), fields
(array), args (array)). I've attached the code below.

Thanks for your help,
Ben


function views_service_service() {
  return array(
array(
  '#method'   = 'views.getView',
  '#callback' = 'views_service_get_view',
  '#args' = array('string', 'array', 'array'),
  '#args' = array(
array(
  '#name' = 'view_name',
  '#type' = 'string',
  '#description'  = t('View name.')),
array(
  '#name' = 'fields',
  '#type' = 'array',
  '#optional' = TRUE, 
  '#description'  = t('A list of fields to return.')),
array(
  '#name' = 'args',
  '#type' = 'array',
  '#optional' = TRUE,
  '#description'  = t('An array of arguments to pass to the
view.'))),
  '#return'   = 'array',
  '#help' = t('Retrieves a view defined in views.module.')),
  );
}


--- In flexcoders@yahoogroups.com, twcrone70 [EMAIL PROTECTED] wrote:

 Method signature is my attempt to be language neutral when asking for
 the interface like in Java it might be:
 
 public List getSomething( int param, String param );
 
 The getNodes() call does not matter.  What matter is the RemoteObject
 method call.  It appears to me that you are passing different
 parameters in the AS implementation as you are the MXML implementation.
 
 I'll look again, but quite often I send the wrong types of parameters
 through an RO and the server side cannot find the method properly.
 
 With PHP, not really sure how an interface or method looks.
 
 - Todd
 
 
 --- In flexcoders@yahoogroups.com, bennybobw bennybobw@ wrote:
 
  Todd,
  That's the part I dont understand. If I use either the mxml or the
  javascript, init() is calling getNodes() in both cases. It works when
  I use the mxml instead of the remoteObject declaration. That's why I
  am thinking it has something to do with my use of remoteObject.
  
  I'm not exactly sure what you mean by server code signature, but I'm
  running Drupal 5 with services and the AMFPHP module.
  
  Thanks,
  Ben
  
  --- In flexcoders@yahoogroups.com, twcrone70 twcrone70@ wrote:
  
   Well at first glance it appears that you are passing parameters
in the
   actionscript and not in the MXML so they are each looking for a
   different method on the server.  When I get no such method
error it
   is usually because I have specified the wrong parameters or in the
   wrong order.  What is the server code signature?
   
   - Todd
  
 





[flexcoders] Re: Newbie, RemoteObject with ActionScript

2008-03-31 Thread valdhor
I am a relative newbie myself but don't you need a views.source =
location of service on server?


--- In flexcoders@yahoogroups.com, bennybobw [EMAIL PROTECTED] wrote:

 Hi All,
 I'm trying to get the following remoteObject working with
 Actionscript. When I use the mxml it works great. But when I compile
 with the actionscript, removing mxml I get an error Method does not
 exist. This doesn't make a lot of sense to me...
 I've also tried views.addEventListener(ResultEvent.RESULT,
onViewsResult);
 
 Still, no dice. I'm struggling to understand how the two are different.
 
 Thanks for your help.
 
 -bennybobw
 
 ?xml version=1.0 encoding=utf-8?
 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
 layout=absolute creationComplete=init()
   mx:Script
![CDATA[
 import mx.controls.*;
 import mx.rpc.events.*;
 import mx.utils.ArrayUtil;
 import mx.rpc.events.FaultEvent;
 
 import mx.rpc.events.InvokeEvent;
 
 import mx.rpc.events.ResultEvent;
 import mx.rpc.remoting.RemoteObject;
 import mx.rpc.remoting.Operation;
 
 
 [Bindable]
 public var nodes:Array;
 
 public var views:RemoteObject;
 
 public function init():void {
   views = new RemoteObject();
   views.destination = amfphp;
   views.addEventListener(ResultEvent.RESULT, onViewsResult);
   views.addEventListener(FaultEvent.FAULT, onFault);
   getNodes();
 }
 
 public function onFault(event:FaultEvent):void {
   Alert.show(event.fault.faultString, Error);
 }
 
 public function onViewsResult(event:ResultEvent):void
 {
   nodes = ArrayUtil.toArray(event.result);
 }
 
 public function getNodes():void {
   views.getView(test, ['nid','title','body','changed']);
 }
 

 
]]
   /mx:Script
 
   !--mx:RemoteObject showBusyCursor=true destination=amfphp
 source=views id=views
 mx:method name=getView result=onViewsResult(event)
 fault=onFault(event) /
   /mx:RemoteObject--
 
   mx:Panel width=500 height=500 layout=absolute title=Nodes
 horizontalCenter=0 verticalCenter=0
 mx:DataGrid x=10 y=10 width=460 id=nodes_select
 dataProvider={nodes} 
   mx:columns
 mx:DataGridColumn headerText=NID dataField=nid width=40/
 mx:DataGridColumn headerText=Title dataField=title/
   /mx:columns
 /mx:DataGrid
 
 mx:Label x=10 y=200 text=Title/
 
 mx:TextInput x=10 y=226 width=460 id=title
 text={nodes_select.selectedItem.title}/
 
 mx:Label x=10 y=256 text=Body/
 
 mx:TextArea x=10 y=282 width=460 height=75 id=body
 text={nodes_select.selectedItem.body}/
 
 
   /mx:Panel
 /mx:Application





Re: [flexcoders] Re: Newbie, RemoteObject with ActionScript

2008-03-31 Thread Aaron Miller
I'm not an expert on RemoteObject myself, but I do notice your code looks a
bit different then mine (which works).

Here is an example of a function that uses remote object in my project:

# public function loadFavorites( resultHandler:Function,
errorHandler:Function ): void {
#   var dataService:RemoteObject = new RemoteObject();
#
#   dataService.destination = amfphp;
#   dataService.source = FavoritesProxy;
#   dataService.loadFavorites.addEventListener( ResultEvent.RESULT,
resultHandler );
#   dataService.addEventListener(FaultEvent.FAULT, errorHandler);
#   dataService.loadFavorites( myUser.userID, myUser.userHash );
# }

The service being FavoritesProxy.loadFavorites

The two differences I notice is on your result addEventListener, and lack of
a 'source' property.

Hope this helps,
~Aaron

On Mon, Mar 31, 2008 at 8:30 AM, valdhor [EMAIL PROTECTED] wrote:

   I am a relative newbie myself but don't you need a views.source =
 location of service on server?


 --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com,
 bennybobw [EMAIL PROTECTED] wrote:
 
  Hi All,
  I'm trying to get the following remoteObject working with
  Actionscript. When I use the mxml it works great. But when I compile
  with the actionscript, removing mxml I get an error Method does not
  exist. This doesn't make a lot of sense to me...
  I've also tried views.addEventListener(ResultEvent.RESULT,
 onViewsResult);
 
  Still, no dice. I'm struggling to understand how the two are different.
 
  Thanks for your help.
 
  -bennybobw
 
  ?xml version=1.0 encoding=utf-8?
  mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
  layout=absolute creationComplete=init()
  mx:Script
  ![CDATA[
  import mx.controls.*;
  import mx.rpc.events.*;
  import mx.utils.ArrayUtil;
  import mx.rpc.events.FaultEvent;
 
  import mx.rpc.events.InvokeEvent;
 
  import mx.rpc.events.ResultEvent;
  import mx.rpc.remoting.RemoteObject;
  import mx.rpc.remoting.Operation;
 
 
  [Bindable]
  public var nodes:Array;
 
  public var views:RemoteObject;
 
  public function init():void {
  views = new RemoteObject();
  views.destination = amfphp;
  views.addEventListener(ResultEvent.RESULT, onViewsResult);
  views.addEventListener(FaultEvent.FAULT, onFault);
  getNodes();
  }
 
  public function onFault(event:FaultEvent):void {
  Alert.show(event.fault.faultString, Error);
  }
 
  public function onViewsResult(event:ResultEvent):void
  {
  nodes = ArrayUtil.toArray(event.result);
  }
 
  public function getNodes():void {
  views.getView(test, ['nid','title','body','changed']);
  }
 
 
 
  ]]
  /mx:Script
 
  !--mx:RemoteObject showBusyCursor=true destination=amfphp
  source=views id=views
  mx:method name=getView result=onViewsResult(event)
  fault=onFault(event) /
  /mx:RemoteObject--
 
  mx:Panel width=500 height=500 layout=absolute title=Nodes
  horizontalCenter=0 verticalCenter=0
  mx:DataGrid x=10 y=10 width=460 id=nodes_select
  dataProvider={nodes} 
  mx:columns
  mx:DataGridColumn headerText=NID dataField=nid width=40/
  mx:DataGridColumn headerText=Title dataField=title/
  /mx:columns
  /mx:DataGrid
 
  mx:Label x=10 y=200 text=Title/
 
  mx:TextInput x=10 y=226 width=460 id=title
  text={nodes_select.selectedItem.title}/
 
  mx:Label x=10 y=256 text=Body/
 
  mx:TextArea x=10 y=282 width=460 height=75 id=body
  text={nodes_select.selectedItem.body}/
 
 
  /mx:Panel
  /mx:Application
 

  



[flexcoders] Re: Newbie, RemoteObject with ActionScript

2008-03-31 Thread twcrone70
Ok, I guess so.  I really didn't look close enough.  I'm no PHP guy so
I might be overstepping.  The only other thing I see that might be a
problem is that the mxml specifies the 'source' property and the
actionscript does not.  But honestly all my RO's are AS and their
endpoints are Java/Spring services that I specify in the
services-config.xml.  I've never used an MXML RO and I use
ItemResponders rather than even listeners.  My AS code typically looks
like this with the destination etc. configured in the services-config.xml.


var service:RemoteObject = new RemoteObject( destinationId );
var customer:Customer = new Customer();
...
var at:AsyncToken = service.createCustomer( customer );
   
at.addResponder( new Responder( onCustomerCreated, faultHandler ) );



Sorry if I've only confused things more...

- Todd


--- In flexcoders@yahoogroups.com, bennybobw [EMAIL PROTECTED] wrote:

 Todd,
 Sorry, I think I'm misunderstanding something very basic here. Aren't
 both mxml and RO calling the method views.getView(test,
 ['nid','title','body','changed'])?
 
 The method server side is views.getView(view name (string), fields
 (array), args (array)). I've attached the code below.
 
 Thanks for your help,
 Ben
 
 
 function views_service_service() {
   return array(
 array(
   '#method'   = 'views.getView',
   '#callback' = 'views_service_get_view',
   '#args' = array('string', 'array', 'array'),
   '#args' = array(
 array(
   '#name' = 'view_name',
   '#type' = 'string',
   '#description'  = t('View name.')),
 array(
   '#name' = 'fields',
   '#type' = 'array',
   '#optional' = TRUE, 
   '#description'  = t('A list of fields to return.')),
 array(
   '#name' = 'args',
   '#type' = 'array',
   '#optional' = TRUE,
   '#description'  = t('An array of arguments to pass to the
 view.'))),
   '#return'   = 'array',
   '#help' = t('Retrieves a view defined in views.module.')),
   );
 }
 
 
 --- In flexcoders@yahoogroups.com, twcrone70 twcrone70@ wrote:
 
  Method signature is my attempt to be language neutral when asking for
  the interface like in Java it might be:
  
  public List getSomething( int param, String param );
  
  The getNodes() call does not matter.  What matter is the RemoteObject
  method call.  It appears to me that you are passing different
  parameters in the AS implementation as you are the MXML
implementation.
  
  I'll look again, but quite often I send the wrong types of parameters
  through an RO and the server side cannot find the method properly.
  
  With PHP, not really sure how an interface or method looks.
  
  - Todd
  
  
  --- In flexcoders@yahoogroups.com, bennybobw bennybobw@ wrote:
  
   Todd,
   That's the part I dont understand. If I use either the mxml
or the
   javascript, init() is calling getNodes() in both cases. It works
when
   I use the mxml instead of the remoteObject declaration. That's why I
   am thinking it has something to do with my use of remoteObject.
   
   I'm not exactly sure what you mean by server code signature,
but I'm
   running Drupal 5 with services and the AMFPHP module.
   
   Thanks,
   Ben
   
   --- In flexcoders@yahoogroups.com, twcrone70 twcrone70@ wrote:
   
Well at first glance it appears that you are passing parameters
 in the
actionscript and not in the MXML so they are each looking for a
different method on the server.  When I get no such method
 error it
is usually because I have specified the wrong parameters or in the
wrong order.  What is the server code signature?

- Todd
   
  
 





[flexcoders] Re: Newbie, RemoteObject with ActionScript

2008-03-31 Thread bennybobw
Thanks Todd and Aaron,
Adding the .source attribute did the trick.

Ben

--- In flexcoders@yahoogroups.com, twcrone70 [EMAIL PROTECTED] wrote:

 Ok, I guess so.  I really didn't look close enough.  I'm no PHP guy so
 I might be overstepping.  The only other thing I see that might be a
 problem is that the mxml specifies the 'source' property and the
 actionscript does not.  But honestly all my RO's are AS and their
 endpoints are Java/Spring services that I specify in the
 services-config.xml.  I've never used an MXML RO and I use
 ItemResponders rather than even listeners.  My AS code typically looks
 like this with the destination etc. configured in the
services-config.xml.
 
 
 var service:RemoteObject = new RemoteObject( destinationId );
 var customer:Customer = new Customer();
 ...
 var at:AsyncToken = service.createCustomer( customer );
  
 at.addResponder( new Responder( onCustomerCreated, faultHandler ) );
 
 
 
 Sorry if I've only confused things more...
 
 - Todd
 
 
 --- In flexcoders@yahoogroups.com, bennybobw bennybobw@ wrote:
 
  Todd,
  Sorry, I think I'm misunderstanding something very basic here. Aren't
  both mxml and RO calling the method views.getView(test,
  ['nid','title','body','changed'])?
  
  The method server side is views.getView(view name (string), fields
  (array), args (array)). I've attached the code below.
  
  Thanks for your help,
  Ben
  
  
  function views_service_service() {
return array(
  array(
'#method'   = 'views.getView',
'#callback' = 'views_service_get_view',
'#args' = array('string', 'array', 'array'),
'#args' = array(
  array(
'#name' = 'view_name',
'#type' = 'string',
'#description'  = t('View name.')),
  array(
'#name' = 'fields',
'#type' = 'array',
'#optional' = TRUE, 
'#description'  = t('A list of fields to return.')),
  array(
'#name' = 'args',
'#type' = 'array',
'#optional' = TRUE,
'#description'  = t('An array of arguments to pass to the
  view.'))),
'#return'   = 'array',
'#help' = t('Retrieves a view defined in views.module.')),
);
  }
  
  
  --- In flexcoders@yahoogroups.com, twcrone70 twcrone70@ wrote:
  
   Method signature is my attempt to be language neutral when
asking for
   the interface like in Java it might be:
   
   public List getSomething( int param, String param );
   
   The getNodes() call does not matter.  What matter is the
RemoteObject
   method call.  It appears to me that you are passing different
   parameters in the AS implementation as you are the MXML
 implementation.
   
   I'll look again, but quite often I send the wrong types of
parameters
   through an RO and the server side cannot find the method properly.
   
   With PHP, not really sure how an interface or method looks.
   
   - Todd
   
   
   --- In flexcoders@yahoogroups.com, bennybobw bennybobw@ wrote:
   
Todd,
That's the part I dont understand. If I use either the mxml
 or the
javascript, init() is calling getNodes() in both cases. It works
 when
I use the mxml instead of the remoteObject declaration. That's
why I
am thinking it has something to do with my use of remoteObject.

I'm not exactly sure what you mean by server code signature,
 but I'm
running Drupal 5 with services and the AMFPHP module.

Thanks,
Ben

--- In flexcoders@yahoogroups.com, twcrone70 twcrone70@ wrote:

 Well at first glance it appears that you are passing parameters
  in the
 actionscript and not in the MXML so they are each looking for a
 different method on the server.  When I get no such method
  error it
 is usually because I have specified the wrong parameters or
in the
 wrong order.  What is the server code signature?
 
 - Todd

   
  
 





[flexcoders] Re: Newbie, RemoteObject with ActionScript

2008-03-30 Thread bennybobw
Todd,
That's the part I dont understand. If I use either the mxml or the
javascript, init() is calling getNodes() in both cases. It works when
I use the mxml instead of the remoteObject declaration. That's why I
am thinking it has something to do with my use of remoteObject.

I'm not exactly sure what you mean by server code signature, but I'm
running Drupal 5 with services and the AMFPHP module.

Thanks,
Ben

--- In flexcoders@yahoogroups.com, twcrone70 [EMAIL PROTECTED] wrote:

 Well at first glance it appears that you are passing parameters in the
 actionscript and not in the MXML so they are each looking for a
 different method on the server.  When I get no such method error it
 is usually because I have specified the wrong parameters or in the
 wrong order.  What is the server code signature?
 
 - Todd
 




[flexcoders] Re: Newbie, RemoteObject with ActionScript

2008-03-30 Thread twcrone70
Method signature is my attempt to be language neutral when asking for
the interface like in Java it might be:

public List getSomething( int param, String param );

The getNodes() call does not matter.  What matter is the RemoteObject
method call.  It appears to me that you are passing different
parameters in the AS implementation as you are the MXML implementation.

I'll look again, but quite often I send the wrong types of parameters
through an RO and the server side cannot find the method properly.

With PHP, not really sure how an interface or method looks.

- Todd


--- In flexcoders@yahoogroups.com, bennybobw [EMAIL PROTECTED] wrote:

 Todd,
 That's the part I dont understand. If I use either the mxml or the
 javascript, init() is calling getNodes() in both cases. It works when
 I use the mxml instead of the remoteObject declaration. That's why I
 am thinking it has something to do with my use of remoteObject.
 
 I'm not exactly sure what you mean by server code signature, but I'm
 running Drupal 5 with services and the AMFPHP module.
 
 Thanks,
 Ben
 
 --- In flexcoders@yahoogroups.com, twcrone70 twcrone70@ wrote:
 
  Well at first glance it appears that you are passing parameters in the
  actionscript and not in the MXML so they are each looking for a
  different method on the server.  When I get no such method error it
  is usually because I have specified the wrong parameters or in the
  wrong order.  What is the server code signature?
  
  - Todd
 





[flexcoders] Re: Newbie, RemoteObject with ActionScript

2008-03-29 Thread twcrone70
Well at first glance it appears that you are passing parameters in the
actionscript and not in the MXML so they are each looking for a
different method on the server.  When I get no such method error it
is usually because I have specified the wrong parameters or in the
wrong order.  What is the server code signature?

- Todd

--- In flexcoders@yahoogroups.com, bennybobw [EMAIL PROTECTED] wrote:

 Hi All,
 I'm trying to get the following remoteObject working with
 Actionscript. When I use the mxml it works great. But when I compile
 with the actionscript, removing mxml I get an error Method does not
 exist. This doesn't make a lot of sense to me...
 I've also tried views.addEventListener(ResultEvent.RESULT,
onViewsResult);
 
 Still, no dice. I'm struggling to understand how the two are different.
 
 Thanks for your help.
 
 -bennybobw
 
 ?xml version=1.0 encoding=utf-8?
 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
 layout=absolute creationComplete=init()
   mx:Script
![CDATA[
 import mx.controls.*;
 import mx.rpc.events.*;
 import mx.utils.ArrayUtil;
 import mx.rpc.events.FaultEvent;
 
 import mx.rpc.events.InvokeEvent;
 
 import mx.rpc.events.ResultEvent;
 import mx.rpc.remoting.RemoteObject;
 import mx.rpc.remoting.Operation;
 
 
 [Bindable]
 public var nodes:Array;
 
 public var views:RemoteObject;
 
 public function init():void {
   views = new RemoteObject();
   views.destination = amfphp;
   views.addEventListener(ResultEvent.RESULT, onViewsResult);
   views.addEventListener(FaultEvent.FAULT, onFault);
   getNodes();
 }
 
 public function onFault(event:FaultEvent):void {
   Alert.show(event.fault.faultString, Error);
 }
 
 public function onViewsResult(event:ResultEvent):void
 {
   nodes = ArrayUtil.toArray(event.result);
 }
 
 public function getNodes():void {
   views.getView(test, ['nid','title','body','changed']);
 }
 

 
]]
   /mx:Script
 
   !--mx:RemoteObject showBusyCursor=true destination=amfphp
 source=views id=views
 mx:method name=getView result=onViewsResult(event)
 fault=onFault(event) /
   /mx:RemoteObject--
 
   mx:Panel width=500 height=500 layout=absolute title=Nodes
 horizontalCenter=0 verticalCenter=0
 mx:DataGrid x=10 y=10 width=460 id=nodes_select
 dataProvider={nodes} 
   mx:columns
 mx:DataGridColumn headerText=NID dataField=nid width=40/
 mx:DataGridColumn headerText=Title dataField=title/
   /mx:columns
 /mx:DataGrid
 
 mx:Label x=10 y=200 text=Title/
 
 mx:TextInput x=10 y=226 width=460 id=title
 text={nodes_select.selectedItem.title}/
 
 mx:Label x=10 y=256 text=Body/
 
 mx:TextArea x=10 y=282 width=460 height=75 id=body
 text={nodes_select.selectedItem.body}/
 
 
   /mx:Panel
 /mx:Application