Zend Framework

Unable to send ArrayCollection as input argument from flex

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.8.0
  • Fix Version/s: 1.8.2
  • Component/s: Zend_Amf
  • Labels:
    None

Description

Trying to send an ArrayCollection from flex to ZendAMF leads to following error:

<br />
<b>Fatal error</b>: Uncaught exception 'Zend_Amf_Exception' with message 'Unable to parse null body data flex.messaging.io.ArrayCollection mapped class is not defined' in C:\wamp\www\ZendFramework\library\Zend\Amf\Request.php:174
Stack trace:
#0 C:\wamp\www\ZendFramework\library\Zend\Amf\Request.php(125): Zend_Amf_Request->readBody()
#1 C:\wamp\www\ZendFramework\library\Zend\Amf\Request.php(93): Zend_Amf_Request->readMessage(Object(Zend_Amf_Parse_InputStream))
#2 C:\wamp\www\ZendFramework\library\Zend\Amf\Request\Http.php(64): Zend_Amf_Request->initialize('??????null/...')
#3 C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php(432): Zend_Amf_Request_Http->__construct()
#4 C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php(374): Zend_Amf_Server->getRequest()
#5 C:\wamp\www\TestZend1-debug\gateway.php(50): Zend_Amf_Server->handle()
#6 {main}
thrown in <b>C:\wamp\www\ZendFramework\library\Zend\Amf\Request.php</b> on line <b>174</b><br />

Sample code to do this can be:

<RemoteObject id="srv" endpoint="http://localhost/TestZend1-debug/gateway.php" destination="createItem" source="Test" result="remoteobject1_resultHandler(event)" fault="srv_faultHandler(event)"/>

protected function fxapplication1_creationCompleteHandler(event:FlexEvent):void
{
var a:ArrayCollection = new ArrayCollection();

a.addItem('hello');

a.addItem('world');

srv.createItem(a);
}

ArrayCollections should be supported as it is widely used in flex.

Activity

Hide
Stanislav Malyshev added a comment -

Fixed - ArrayCollection now is converted to array.

Show
Stanislav Malyshev added a comment - Fixed - ArrayCollection now is converted to array.
Hide
shibby added a comment -

Stanislav,

I tried with the code supplied by Gaurav Priyadarshi and had no success retrieving the ArrayCollection on my php class.

Would you mind putting an example on how to send the ArrayCollection to PHP and use it there now that the issue is fixed?

Thanks in advance.

Show
shibby added a comment - Stanislav, I tried with the code supplied by Gaurav Priyadarshi and had no success retrieving the ArrayCollection on my php class. Would you mind putting an example on how to send the ArrayCollection to PHP and use it there now that the issue is fixed? Thanks in advance.
Hide
shibby added a comment -

I figured it out myself.

On your flex code convert your ArrayCollections to Array and you are ready to go.

<RemoteObject id="srv" endpoint="http://localhost/TestZend1-debug/gateway.php" destination="createItem" source="Test" result="remoteobject1_resultHandler(event)" fault="srv_faultHandler(event)"/>

protected function fxapplication1_creationCompleteHandler(event:FlexEvent):void

{ var a:ArrayCollection = new ArrayCollection(); a.addItem('hello'); a.addItem('world'); var b:Array = a.toArray(); srv.createItem(b); }
Show
shibby added a comment - I figured it out myself. On your flex code convert your ArrayCollections to Array and you are ready to go. <RemoteObject id="srv" endpoint="http://localhost/TestZend1-debug/gateway.php" destination="createItem" source="Test" result="remoteobject1_resultHandler(event)" fault="srv_faultHandler(event)"/> protected function fxapplication1_creationCompleteHandler(event:FlexEvent):void { var a:ArrayCollection = new ArrayCollection(); a.addItem('hello'); a.addItem('world'); var b:Array = a.toArray(); srv.createItem(b); }

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: