On 7/14/06, Andrea Varga <[EMAIL PROTECTED]> wrote:
> Hi All!
>
> I'm going to ask my question through an example. (I'm using Cairngorm,
> but I think the problem is general)
> Let's say I have a database with 2 tables:
>
> 1. user -> with fields: user_id, user_name, user_country_id (foreign
> key from country table)
> 2. countries -> with fields: country_id, country_name
>
> Let's say I need an application that lists all the users, in a datagrid
> with 2 columns: User Name, Country Name.
> How should I approach this?
>
> Let's say I have 2 VO's, to reflect the database structure:
>
> class UserVO {
> public var ID:int;
> public var name:String;
> public var countryID:int;
> }
>
> class CountryVO {
> public var ID:int;
> public var name:String;
> }
>
> And I have in my Model:
>
> users:ArrayCollection; // array collection of UserVOs
> countries:ArrayCollection; // array collection of CountryVOs
>
> How could I create a binding of users to a Datagrid, so it will display
> the country names?
> Or how else should I approach the problem?
>
> In case I have:
> class UserVO {
> public var ID:int;
> public var name:String;
> public var country:countryVO;
> }
>
> I think the bindig would be possibe, but a bunch of other
> questions/problems appear.
> Eg.:
> I'm using remoting to get the data from the server (AMFHP).
> On one hand: Class mappings won't work with VO's insite another VO.
who says? Works for me. In your case maybe try
<mx:DataGridColumn dataField="userVO.countryVO.name" headerText="Country"/> ???
> On second hand: I have to load the list of countries (I need it
> somewhere else), and I would not want to carry the CountryVO inside the
> UserVO, for many reasons. One of them is: this is a simple example, but
> what if CountryVO is a more complex data, and i need to send a userVO to
> the server (to update the database for example), I don't need a
> CountryVO there, just a UserVO that has the ID of a country.
Another way maybe to just add countryName:string to your userVO.
Depends on what you need userVO to fully model.
DK
>
> Thanks,
> Andi
>
>
>
>
>
>
>
>
>
> --
> 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
>
>
>
>
>
>
>
--
Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it?
------------------------ Yahoo! Groups Sponsor --------------------~-->
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~->
--
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
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/