Ah, it looks like you have taken both my *and* Dave's advice, when you
really only needed to do one or the other. So, if you don't have a
problem with making your firstname and lastname variables public in
your UserProfileForm POJO (which you might, since it kind of defeats
the purpose of getters and setters), then just pass your datagrid a
collection of UserProfileForms:
<mx:DataGrid dataProvider="{myUserProfileFormCollection}" />
This will display the entire object in the datagrid. If you only want
to see certain fields, or want to specify a specific order, define
columns for the datagrid like so:
<mx:DataGrid dataProvider="{myUserProfileFormCollection}">
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="firstname"
headerText="First Name"/>
<mx:DataGridColumn columnName="lastname"
headerText="Last Name"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>
If, however, you want to keep the members variables of your objects
hidden and provide access only through getters and setters, then
change the declarations back to private and follow Dave's advice.
I hope that helps!
Doug
--- In [email protected], "sshriyan27" <[EMAIL PROTECTED]> wrote:
>
> Let me send you all my classes, i don't still understand! Thanks for
> your help anyway.
>
> public class UserProfileForm {
>
> public String firstname=null;
> public String lastname=null;
>
> public UserProfileForm(){}
>
> public String getFirstname() {
> return firstname;
> }
> public void setFirstname(String firstname) {
> this.firstname = firstname;
> }
> public String getLastname() {
> return lastname;
> }
> public void setLastname(String lastname) {
> this.lastname = lastname;
> }
>
> }
>
> public class CloserResultsForm implements Serializable{
> public UserProfileForm userProfileForm;
>
> public CloserResultsForm(){
> userProfileForm=new UserProfileForm();
> }
> public UserProfileForm getUserProfileForm() {
> return userProfileForm;
> }
> public void setUserProfileForm(UserProfileForm
> userProfileForm) {
> this.userProfileForm = userProfileForm;
> }
>
> }
>
> ** my dataaccess returns collection of CloserResultsForm
>
> CloserResultsForm.as file
> class src.com.flex.form.CloserResultsForm{
> public var userProfileForm : UserProfileForm;
>
> static var registered=Object.registerClass
> ("com.chl.form.CloserResultsForm",
> src.com.flex.form.CloserResultsForm);
>
> public function CloserResultsForm(){
> this.userProfileForm=new UserProfileForm();
> }
> }
>
> UserProfileForm.as file
> class src.com.flex.form.UserProfileForm{
> public var firstname:String;
> public var lastname:String;
> public var _remoteClass;
> static var registered=Object.registerClass
> ("com.chl.form.UserProfileForm", src.com.flex.form.UserProfileForm);
>
> }
>
> How do i print the firstname and lastname in datagrid, am i missing
> something here.
>
> --- In [email protected], "Dave Wolf" <[EMAIL PROTECTED]> wrote:
> >
> > Ahh yes, the same J2EE struggles with property setting. As Doug
> says
> > you do not want to be calling a million setters on a remote object.
> > You are better off refactoring this to either create a new Value
> > Object, or to treat your existing class itself as a value object.
> >
> > So rather then getting a remote reference to say UserProfileForm,
> then
> > calling a million getters and setters, I would create a POJO which
> > returns the UserProfileForm as a return type. Then call all your
> > setters locally, and pass it back up to the server as the
> parameter to
> > another POJO method call.
> >
> > The second option is to add a new Value Object property to the
> > UserProfileForm. Again create the stub, call all the setters on
> the
> > local value object, then call one call on the UserProfileForm to
> > return this coarsly grained Value Object.
> >
> > You need to keep network calls in mind in your architecture.
> There is
> > a graveyard filled with failed J2EE projects who ignored the
> network
> > and the effects of not architecting around seriously reducing the
> > number and size of remote calls.
> >
> > --
> > Dave Wolf
> > Cynergy Systems, Inc.
> > Macromedia Flex Alliance Partner
> > http://www.cynergysystems.com
> >
> > Email: [EMAIL PROTECTED]
> > Office: 866-CYNERGY
> >
> >
> > --- In [email protected], "douglowder" <[EMAIL PROTECTED]>
> wrote:
> > >
> > > Flex 1.5 does a pretty good job of automatically translating
> Java
> > > types to ActionScript, but only for members that are declared
> > > public, not private. So, if you want to continue using your
> getter
> > > routines for private members in your existing classes, be
> prepared
> > > to make a lot of calls to your remote object. You could also
> create
> > > a new "facade" Java class for mapping purposes, which would have
> > > public members for all the variables you want to expose to
> > > ActionScript, and have that class make all the calls to your
> > > existing class's getters to initialize those public members.
> You
> > > can then refer to the variables by name (the same name as in the
> > > Java class) from within ActionScript.
> > >
> > > Another thing to keep in mind is that datagrids expect to be
> passed
> > > arrays (actually, anything that implements the DataProvider
> > > interface) of objects, not a single object. If your Java calls
> are
> > > returning a single object instead of a list of objects, use
> > > mx.utils.ArrayUtil.toArray() on the result to convert it to an
> array
> > > in ActionScript.
> > >
> > > Doug
> > >
> > >
> > > --- In [email protected], "sshriyan27"
> <[EMAIL PROTECTED]>
> > > wrote:
> > > >
> > > > I'm new to Flex we're trying evaluate in our company whether
> we
> > > > should use FLEX or not. Right we have Java, Struts based
> > > application.
> > > >
> > > > I have a simple question, i have an Object and still strugling
> to
> > > > map that to an action script and datagrid.
> > > > How do i display values of UserProfileForm in datagrid, like
> in
> > > > Struts i used to do
> CloserResultsForm.userProfileForm.firstname
> > > ();
> > > > Can some one explain this to me.
> > > > ** I can get the Single object to get displayed but not the
> > > > inhertited ones.
> > > >
> > > > public class CloserResultsForm implements Serializable{
> > > > private UserProfileForm userProfileForm;
> > > > }
> > > >
> > > > public class UserProfileForm {
> > > > private String username=null;
> > > > private int userid;
> > > > private String password=null;
> > > > private String firstname=null;
> > > > private String lastname=null;
> > > > private String roleName=null;
> > > >
> > > > public UserProfileForm(){
> > > >
> > > > }
> > > > .... // then getters and setters for the above
> > > > }
> > > >
> > >
> >
>
--
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/