Hi,
Using ASObject I m able to exchange data from .NET to Flex. But I have 2 questions :
1) Will there be any changes required, when migrating to future versions of Flex, as in Flex 2.0, which is going to support .NET? Can we still retain ASObject or should we change them to Custom classes.
2)Does this hold good even for Java? i.e Do I have to use ASObject to exchange data from Java to Flex, or is it possible to pass custom classes itself from Java to Flex.
Regards
Priyanka
superabe superabe <[EMAIL PROTECTED]> wrote:
sorry typo (or cut'n'pasto)
===
ASObject title =
title.ASType = "RemoteTest.Title"
new ASObject();
===
SHOULD BE
====
ASObject title = new ASObject();
title.ASType = "RemoteTest.Title"
- superabe
On 8/3/05, superabe superabe <[EMAIL PROTECTED]> wrote:
> Hmm AFAIK, you cannot return a custom class from .Net back to Flex
> like that (yet)..I could be wrong here so if somebody knows
> otherwise...please do tell :-)
>
> Try this instead :
>
> //=========
>
> public
>
> ASObject getEmployee(string au_id)
> {
>
> conn =
>
> new SqlConnection("data source=dt1305-priyanka\\netsdk;
> database=pubs;uid=sa;pwd=welcome;");
> conn.Open();
>
> SqlCommand sqlcomm =
>
> new SqlCommand();
>
> sqlcomm.Connection=conn;
>
> sqlcomm.CommandType = CommandType.Text;
>
> sqlcomm.CommandText = "SELECT * FROM titleauthor WHERE au_id ='" + au_id + "'";
>
> SqlDataReader readerObj = sqlcomm.ExecuteReader();
>
> ASObject title =
> title.ASType = "RemoteTest.Title"
> new ASObject();
>
> while (readerObj.Read())
> {
>
> title.AddKey("au_id",au_id);
>
> title.AddKey("title_id" , readerObj.GetString(1));
>
> title.AddKey("au_ord", (System.Byte)readerObj.GetValue(2));
>
> title.AddKey("royaltyper", (Int32)readerObj.GetValue(3));
>
> }
>
>
> return title;
> }
>
> HTH
> - superabe
>
>
>
> On 8/3/05, priya s <[EMAIL PROTECTED]> wrote:
> > Hi all,
> > I m trying to return a custom object from .NET to Flex. It s returning
> > Nothing. But I m able to send the same custom object from Flex to .NET.
> >
> > 1) The addTitle method, in which I am passing a custom object from Flex to
> > .NET is working fine.
> > 2) In GetTitle method, where I am returning a custom object from .NET to
> > Flex, I am getting undefined. (I have data in the database, for the same
> > inputs, the method is working fine from an .aspx page, so its not that there
> > is no data)
> >
> > Is there something that I am missing out?
> > MXML
> >
> > <?xml version="1.0" encoding="utf-8"?>
> >
> > <mx:Application
> > xmlns:mx="http://www.macromedia.com/2003/mxml"
> > backgroundColor="#FFFFFF"
> > initialize="initApp()">
> >
> > <mx:Script>
> > import RemoteTest.Title;
> >
> > var title:RemoteTest.Title;
> >
> > function initApp() {
> > title=new Title();
> > }
> >
> > function addTitle() {
> > title.au_id=au_id.text;
> > title.title_id=title_id.text;
> > title.au_ord=Number(au_ord.text);
> > title.royaltyper=Number(royaltyper.text);
> > srv.addEmployee(title);
> > }
> >
> > function getTitle() {
> > srv.getEmployee(au_id.text);
> > }
> >
> > function onGetData(event:Object):Void {
> > title = event.result;
> > title_id.text = title.title_id;
> >
> > }
> > </mx:Script>
> >
> > <mx:RemoteObject id="srv" source="RemoteTest.Sample">
> > <mx:method name="addEmployee"/>
> > <mx:method name="getEmployee" result = "onGetData(event)" />
> > </mx:RemoteObject>
> >
> > <mx:Form>
> >
> > <mx:FormItem label="au_id">
> > <mx:TextInput id="au_id"/>
> > </mx:FormItem>
> > <mx:FormItem label="title_id">
> > <mx:TextInput id="title_id"/>
> > </mx:FormItem>
> > <mx:FormItem label="au_ord">
> > <mx:TextInput id="au_ord"/>
> > </mx:FormItem>
> > <mx:FormItem label="royaltyper">
> > <mx:TextInput id="royaltyper"/>
> > </mx:FormItem>
> > <mx:FormItem>
> > <mx:Button label="Add Employee" click="addTitle()"/>
> > </mx:FormItem>
> > <mx:FormItem>
> > <mx:Button label="Get Employee" click="getTitle()"/>
> > </mx:FormItem>
> > </mx:Form>
> >
> > </mx:Application>
> > ActionScript
> >
> > // ActionScript Document
> > class RemoteTest.Title {
> >
> > public var au_id : String;
> > public var title_id : String;
> > public var au_ord : Number;
> > public var royaltyper : Number;
> >
> > static var registered=
> > Object.registerClass("RemoteTest.Title", RemoteTest.Title);
> > }
> >
> > .NET class
> >
> >
> >
> > usingSystem;
> >
> > usingFlashGateway.IO;
> >
> > usingSystem.Xml;
> >
> > usingSystem.Data;
> >
> > usingSystem.Data.SqlClient;
> >
> > usingSystem.IO;
> >
> > usingSystem.Text;
> >
> > usingSystem.Collections;
> >
> >
> >
> > namespaceRemoteTest
> >
> > {
> >
> >
> >
> > public class Sample
> >
> >
> >
> > {
> >
> > private SqlConnection conn;
> >
> > public void addEmployee(Title employee)
> >
> > {
> >
> > conn =new SqlConnection("data source=dt1305-priyanka\\netsdk;
> > database=pubs;uid=sa;pwd=welcome;");
> >
> > conn.Open();
> >
> > SqlCommand sqlcomm = new SqlCommand();
> >
> >
> >
> > sqlcomm.Connection=conn;
> >
> > sqlcomm.CommandType = CommandType.Text;
> >
> > sqlcomm.CommandText = "INSERT INTO titleauthor
> > (au_id,title_id,au_ord,royaltyper) VALUES('"+employee.au_id
> > + "','" +employee.title_id +"',"+employee.au_ord +","+employee.royaltyper
> > +")";
> >
> > sqlcomm.ExecuteNonQuery();
> >
> > }
> >
> >
> >
> > publicTitle getEmployee(string au_id)
> >
> > {
> >
> > conn =new SqlConnection("data source=dt1305-priyanka\\netsdk;
> > database=pubs;uid=sa;pwd=welcome;");
> >
> > conn.Open();
> >
> > SqlCommand sqlcomm = new SqlCommand();
> >
> >
> >
> > sqlcomm.Connection=conn;
> >
> > sqlcomm.CommandType = CommandType.Text;
> >
> > sqlcomm.CommandText = "SELECT * FROM titleauthor WHERE au_id ='" + au_id +
> > "'";
> >
> > SqlDataReader readerObj = sqlcomm.ExecuteReader();
> >
> > Title title = new Title();
> >
> > while (readerObj.Read())
> >
> > {
> >
> > title.au_id = au_id;
> >
> > title.title_id = readerObj.GetString(1);
> >
> > title.au_ord = (System.Byte)readerObj.GetValue(2);
> >
> > title.royaltyper = (Int32)readerObj.GetValue(3);
> >
> > }
> >
> > return title;
> >
> > }
> >
> > }
> >
> > }
> > DataObject class in .NET
> >
> >
> >
> > usingSystem;
> >
> > namespaceRemoteTest
> >
> > {
> >
> >
> >
> > [Serializable]
> >
> > public class Title
> >
> > {
> >
> > public string au_id;
> >
> > public string title_id;
> >
> > public int au_ord;
> >
> > public int royaltyper;
> >
> > }
> >
> > }
> > Regards
> > Priyanka
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > --
> > Flexcoders Mailing List
> > FAQ:
> > http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> >
> >
> >
> > SPONSORED LINKS
> > Computer software testing Macromedia flex Development
> > Software developer
> > ________________________________
> > YAHOO! GROUPS LINKS
> >
> > Visit your group "flexcoders" on the web.
> >
> > To unsubscribe from this group, send an email to:
> > [EMAIL PROTECTED]
> >
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> > To unsubscribe from this group, send an email to:
> > [EMAIL PROTECTED]
> >
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> > ________________________________
> >
> >
> >
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

