I am using the WebORB for PHP on my server side. There am doing a SELECT * query and am sending the returned results to Flex.
"How did you create the collection? Did you use AMF? Did you load from XML?" I am using the RemoteObjects in here and configured the VO's at both ends. "Somehow the objects that got created did not get created as the proper UserVO objects. So check the collection when it gets set, it's not getting set right. If you're using AMF then you might need to include a reference to the UserVO class so the compiler knows to include it, otherwise it won't get deserialized right." Am new with PHP stuff, so just experimenting with it to use with Flex. Here is how my class looks like in php: <?php require_once("vo/UserVO.php"); class UserDelegate { public function getUsers() { $link = mysql_connect("localhost", "dbuser", "dbpassword"); mysql_select_db('userdb', $link); $result = mysql_query("SELECT * FROM tbl_user order by userId;")or die("Invalid query: " . mysql_error()); mysql_close($link); return $result; } } ?> So, I am selecting * and returning $result straightforward, in responder(on flex side) am getting this in my arraycollection as below: public function result(data:Object):void { //TODO: implement function var list:ArrayCollection = new ArrayCollection(data.result as Array); // definition of ALL_USERS - public static var ALL_USERS : ICollectionView; ModelLocator.ALL_USERS = list; // $results is being populated to this corresponding collection. } So, on PHP side, am not sure how I would get the result in the form of UserVO and populate the $result with vo's and then send it back to Flex. Thanks for your help. Doug McCune wrote: > > ALL_USERS isn't a collection of UserVO objects it seems. Looks like it's a > collection of generic Objects. How did you create the collection? Did you > use AMF? Did you load from XML? Somehow the objects that got created did > not > get created as the proper UserVO objects. So check the collection when it > gets set, it's not getting set right. If you're using AMF then you might > need to include a reference to the UserVO class so the compiler knows to > include it, otherwise it won't get deserialized right. If you're using > some > other method (like loading XML, etc) then make sure in the parsing of the > data that you are explicitly creating UserVO objects. > > Doug > > On Sun, Jun 1, 2008 at 6:35 AM, Manu Dhanda <[EMAIL PROTECTED]> > wrote: > >> >> Hii >> >> am writing a simple application where for logging in, am checking the >> values >> against the value objects contained in an ArrayCollection. >> >> While >> >> if((evt.userVO.email == ModelLocator.ALL_USERS[i].email) && >> (evt.userVO.pwd >> == ModelLocator.ALL_USERS[i].pwd)) >> >> returns true, then why it throws this Type coercion error at this >> following >> line: >> >> model.currentUser = ModelLocator.ALL_USERS[i]; >> //UserVO(ModelLocator.ALL_USERS[i]); >> >> currentUser is type UserVO and ALL_USERS is a collection of UserVO >> objects. >> >> I had tried by explicitely casting the above line(as commented), but >> still >> the same. >> >> Here is the error, I received while debugging: >> >> Explicit casting:- >> >> TypeError: Error #1034: Type Coercion failed: cannot convert >> [EMAIL PROTECTED] >> to com.live.flats.vo.UserVO. >> at >> >> com.live.flats.commands::LoginInfoCommand/execute()[F:\xampp\htdocs\flats\flex_src\com\live\flats\commands\LoginInfoCommand.as:60] >> at >> >> com.adobe.cairngorm.control::FrontController/executeCommand()[C:\dev\swat\projects\ac_emea\Cairngorm\com\adobe\cairngorm\control\FrontController.as:215] >> at flash.events::EventDispatcher/dispatchEventFunction() >> at flash.events::EventDispatcher/dispatchEvent() >> at >> >> com.adobe.cairngorm.control::CairngormEventDispatcher/dispatchEvent()[C:\dev\swat\projects\ac_emea\Cairngorm\com\adobe\cairngorm\control\CairngormEventDispatcher.as:113] >> at >> >> com.adobe.cairngorm.control::CairngormEvent/dispatch()[C:\dev\swat\projects\ac_emea\Cairngorm\com\adobe\cairngorm\control\CairngormEvent.as:77] >> at >> >> com.live.flats.view::LoginPanelBar/loginUser()[F:\xampp\htdocs\flats\flex_src\com\live\flats\view\LoginPanelBar.mxml:29] >> at >> >> com.live.flats.view::LoginPanelBar/__loginButton_click()[F:\xampp\htdocs\flats\flex_src\com\live\flats\view\LoginPanelBar.mxml:74] >> >> Implicit Casting:- >> >> TypeError: Error #1034: Type Coercion failed: cannot convert >> [EMAIL PROTECTED] >> to com.live.flats.vo.UserVO. >> at >> >> com.live.flats.commands::LoginInfoCommand/execute()[F:\xampp\htdocs\flats\flex_src\com\live\flats\commands\LoginInfoCommand.as:60] >> at >> >> com.adobe.cairngorm.control::FrontController/executeCommand()[C:\dev\swat\projects\ac_emea\Cairngorm\com\adobe\cairngorm\control\FrontController.as:215] >> at flash.events::EventDispatcher/dispatchEventFunction() >> at flash.events::EventDispatcher/dispatchEvent() >> at >> >> com.adobe.cairngorm.control::CairngormEventDispatcher/dispatchEvent()[C:\dev\swat\projects\ac_emea\Cairngorm\com\adobe\cairngorm\control\CairngormEventDispatcher.as:113] >> at >> >> com.adobe.cairngorm.control::CairngormEvent/dispatch()[C:\dev\swat\projects\ac_emea\Cairngorm\com\adobe\cairngorm\control\CairngormEvent.as:77] >> at >> >> com.live.flats.view::LoginPanelBar/loginUser()[F:\xampp\htdocs\flats\flex_src\com\live\flats\view\LoginPanelBar.mxml:29] >> at >> >> com.live.flats.view::LoginPanelBar/__loginButton_click()[F:\xampp\htdocs\flats\flex_src\com\live\flats\view\LoginPanelBar.mxml:74] >> >> Any help would be great. >> Thanks. >> >> -- >> View this message in context: >> http://www.nabble.com/Casting-Problem..-Type-Coercion-Failed-tp17585702p17585702.html >> Sent from the FlexCoders mailing list archive at Nabble.com. >> >> >> > > -- View this message in context: http://www.nabble.com/Casting-Problem..-Type-Coercion-Failed-tp17585702p17595826.html Sent from the FlexCoders mailing list archive at Nabble.com.