[flexcoders] Re: Java POJO/Action Script question

2006-02-03 Thread sshriyan27
Thanks Doug,
I was able to print the child object properties using the 
labelFunction, but the problem is the column is editable, so when 
ever i click that filed it's changing back to [object.object].
Do you have any samples using as script printing child object 
properties in datagrid? 
BTW i changed logger level=Debug in gateway-config file and it's 
was printing all the parent child values from Java.

i appreciate your help.

--- In flexcoders@yahoogroups.com, douglowder [EMAIL PROTECTED] 
wrote:

 I think that design is fine.  I use a similar approach, except 
that my
 POJOs are a combination of entity objects + dataaccess method, i.e.
 each class has a getList() method that returns a list of all known
 instances of that type.  I chose that approach because these were
 POJOs written explicitly with Flex in mind, since this was a new
 project with no existing codebase to work from.  It's entirely up 
to
 you how much separation you want between data access and the 
objects
 themselves.
 
 A case where you might be forced to use a facade class is when you
 have a private member that is determined dynamically in code and
 accessed only through a getter.  In this instance, you could write
 another class that calls the first class's getter and sets a public
 member variable to the results.  This new class would be what your
 RemoteObject calls from Flex.
 
 
 Doug
 
 --- In flexcoders@yahoogroups.com, sshriyan27 sshriyan27@ 
wrote:
 
  Thanks Doug,
  Now i understand. Let me ask you a question then, my design 
consists 
  of 2 parts, i have entity objects and dataaccess objects, each 
time 
  i do a method call in dataaccess obj and it returns either a 
  collection of entity objects or single entity objects to client.
  
  Is this a right way to do or should i use some facade patterns, 
what 
  do you think, since i'm coming struts background it's kind of 
  learning curve for me using flex. I'm not using any EJB's for 
our 
  application. It's a simple 3 tier arch.
  
  thanks
  
  
  
  
  --- In flexcoders@yahoogroups.com, douglowder douglowder@ 
  wrote:
  
   It isn't a case of need.  One reason you might *want* to have 
  public
   members in your POJO is for convenience.  Flex will 
automatically
   handle conversion of Java strings (as well as several other 
types;
   check the documentation) to actionscript, so if your 
RemoteObject
   returns a collection of POJOs with public String members you 
can 
  plug
   that list directly into a grid's dataprovider without any extra
   actionscript code.  This would correspond to collections of 
ClassA 
  and
   ClassB objects, which map nicely to what dataProviders 
expect.  You
   cannot, however, pass a list of Class1 POJOs and expect the 
  datagrid
   to display Class1.ClassA.A1, Class1.ClassB.B1, etc., without 
doing
   some extra work on the actionscript side.  See the difference?
   
   Now, this doesn't mean you *have* to do things either one way 
or
   another.  I'm just trying to explain what I personally think 
is the
   easiest way to get POJO data into a dataGrid in Flex.  If this 
  still
   isn't clear, let me know and I'll try to provide some working 
code.
   
   Hope that helps!
   
   Doug
   
   --- In flexcoders@yahoogroups.com, sshriyan27 sshriyan27@ 
  wrote:
   
Thanks guys for helping me out here, but still i don't 
  understand 
why should i need to have public members firstname,lastname 
etc 
  in 
the CloserResultsForm form, isn't it involves redundancy and 
  hard to 
maintain lots of member variables. 

all i want is this,

Class1 instanciate class A, class B, Class A has member 
  variables 
A1,A2 and Class B has B1,B2 etc,
if i want to display A1, B1 values using Class1, 
i should be saying classA.A1,classA.A2, ClassB.B1, ClassB.B2 
etc,
i don't want to declare A1,A2 in Class1 again in 2 palces.
Am i missing something here about my design pattern? May be 
i'm 
confused.
Pls help me soon.

--- In flexcoders@yahoogroups.com, douglowder 
douglowder@ 
wrote:

 You're almost there!  What you want is for 
CloserDataAccess to 
return
 a list of objects that contain firstname and lastname 
  properties. 
 What you have now is a list of objects that contain other 
  objects 
(the
 UserProfileForms), which then contain firstname and 
lastname.
 
 If your CloserResultsForm java class had public members 
  firstname 
and
 lastname, initialized by calling the proper getters from
 UserProfileForm, your datagrid should work.  This wouldn't 
even
 require the separate ActionScript classes for 
  CloserResultsForm and
 UserProfileForm.
 
 
 Doug
 
 
 --- In flexcoders@yahoogroups.com, sshriyan27 
  [EMAIL PROTECTED] 
wrote:
 
  Thanks but still not working i made them private now.
  I'm totally lost with action script and object mapping.
  Do i need to use action script 

[flexcoders] Re: Java POJO/Action Script question

2006-02-03 Thread douglowder
Sounds like you want a cell renderer for your columns.  For each 
DataGridColumn in your grid, you can add cellRenderer=MyRenderer 
to tell the grid how to determine what should be displayed.  The 
renderer will be passed the object in the dataprovider for each 
particular row, which you can use to determine what to display for 
the specific row and column.

Here's a nice link to info on cell renderers:

http://www.communitymx.com/content/article.cfm?cid=B4AED

You can write cell renderers in either .as or .mxml; search the 
archives and you'll find plenty of examples.  Here's one I use to 
display formatted sizes of file objects.

import mx.controls.Label;

/*
 * FileSizeCellRenderer is a simple Label-based cell renderer that 
displays
 * its item content as a formatted file size string.
 */

class FileSizeCellRenderer extends Label {
var listOwner: MovieClip; // The reference we receive to the 
list.
var getCellIndex: Function; // The function we receive from the 
list.
var getDataLabel: Function; // The function we receive from the 
list.

function setValue(str:String, obj:Object, state:String) : Void {
if (obj != undefined) {
// format the file size value in the cell
this.text = obj.file.getSizeString();
}
else {
this.text = ;
}
}
}


Doug

--- In flexcoders@yahoogroups.com, sshriyan27 [EMAIL PROTECTED] 
wrote:

 Thanks Doug,
 I was able to print the child object properties using the 
 labelFunction, but the problem is the column is editable, so when 
 ever i click that filed it's changing back to [object.object].
 Do you have any samples using as script printing child object 
 properties in datagrid? 
 BTW i changed logger level=Debug in gateway-config file and it's 
 was printing all the parent child values from Java.
 
 i appreciate your help.
 
 --- In flexcoders@yahoogroups.com, douglowder douglowder@ 
 wrote:
 
  I think that design is fine.  I use a similar approach, except 
 that my
  POJOs are a combination of entity objects + dataaccess method, 
i.e.
  each class has a getList() method that returns a list of all 
known
  instances of that type.  I chose that approach because these were
  POJOs written explicitly with Flex in mind, since this was a new
  project with no existing codebase to work from.  It's entirely 
up 
 to
  you how much separation you want between data access and the 
 objects
  themselves.
  
  A case where you might be forced to use a facade class is when 
you
  have a private member that is determined dynamically in code and
  accessed only through a getter.  In this instance, you could 
write
  another class that calls the first class's getter and sets a 
public
  member variable to the results.  This new class would be what 
your
  RemoteObject calls from Flex.
  
  
  Doug
  
  --- In flexcoders@yahoogroups.com, sshriyan27 sshriyan27@ 
 wrote:
  
   Thanks Doug,
   Now i understand. Let me ask you a question then, my design 
 consists 
   of 2 parts, i have entity objects and dataaccess objects, each 
 time 
   i do a method call in dataaccess obj and it returns either a 
   collection of entity objects or single entity objects to 
client.
   
   Is this a right way to do or should i use some facade 
patterns, 
 what 
   do you think, since i'm coming struts background it's kind of 
   learning curve for me using flex. I'm not using any EJB's for 
 our 
   application. It's a simple 3 tier arch.
   
   thanks
   
   
   
   
   --- In flexcoders@yahoogroups.com, douglowder douglowder@ 
   wrote:
   
It isn't a case of need.  One reason you might *want* to 
have 
   public
members in your POJO is for convenience.  Flex will 
 automatically
handle conversion of Java strings (as well as several other 
 types;
check the documentation) to actionscript, so if your 
 RemoteObject
returns a collection of POJOs with public String members you 
 can 
   plug
that list directly into a grid's dataprovider without any 
extra
actionscript code.  This would correspond to collections of 
 ClassA 
   and
ClassB objects, which map nicely to what dataProviders 
 expect.  You
cannot, however, pass a list of Class1 POJOs and expect the 
   datagrid
to display Class1.ClassA.A1, Class1.ClassB.B1, etc., without 
 doing
some extra work on the actionscript side.  See the 
difference?

Now, this doesn't mean you *have* to do things either one 
way 
 or
another.  I'm just trying to explain what I personally think 
 is the
easiest way to get POJO data into a dataGrid in Flex.  If 
this 
   still
isn't clear, let me know and I'll try to provide some 
working 
 code.

Hope that helps!

Doug

--- In flexcoders@yahoogroups.com, sshriyan27 
sshriyan27@ 
   wrote:

 Thanks guys for helping me out here, but still i don't 
   understand 
 why should i need to have public members 
firstname,lastname 
 etc 
   in 

[flexcoders] Re: Java POJO/Action Script question

2006-02-02 Thread sshriyan27
Thanks guys for helping me out here, but still i don't understand 
why should i need to have public members firstname,lastname etc in 
the CloserResultsForm form, isn't it involves redundancy and hard to 
maintain lots of member variables. 

all i want is this,

Class1 instanciate class A, class B, Class A has member variables 
A1,A2 and Class B has B1,B2 etc,
if i want to display A1, B1 values using Class1, 
i should be saying classA.A1,classA.A2, ClassB.B1, ClassB.B2 etc,
i don't want to declare A1,A2 in Class1 again in 2 palces.
Am i missing something here about my design pattern? May be i'm 
confused.
Pls help me soon.

--- In flexcoders@yahoogroups.com, douglowder [EMAIL PROTECTED] 
wrote:

 You're almost there!  What you want is for CloserDataAccess to 
return
 a list of objects that contain firstname and lastname properties. 
 What you have now is a list of objects that contain other objects 
(the
 UserProfileForms), which then contain firstname and lastname.
 
 If your CloserResultsForm java class had public members firstname 
and
 lastname, initialized by calling the proper getters from
 UserProfileForm, your datagrid should work.  This wouldn't even
 require the separate ActionScript classes for CloserResultsForm and
 UserProfileForm.
 
 
 Doug
 
 
 --- In flexcoders@yahoogroups.com, sshriyan27 [EMAIL PROTECTED] 
wrote:
 
  Thanks but still not working i made them private now.
  I'm totally lost with action script and object mapping.
  Do i need to use action script for the value objects i have, if 
that 
  so is there any easy way to write action scripts same as the 
java 
  objects. 
  
  
  mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml; 
  initialize=initApp() xmlns:i2view=view pageTitle=Test 
  Application
  
   mx:Script
import src.com.flex.form.*;

var users: Array;
var upForm: UserProfileForm;
var closerResultsForm: CloserResultsForm;
var userList: Array;
var resultList: Array;

  function initApp() {
   ro.getResults(); // returns CloserResultsForm as a 
  collection
 
  }
  
  function getUserList_result(event) {
  userList=event.result;
  }
  
  function getResultList_result(event) {
 resultList=event.result;
 
  }
   
  
  /mx:Script
   
   mx:RemoteObject id=ro 
  source=com.chl.dataaccess.CloserDataAccess
  mx:method name=getResults result=getResultList_result
  (event)/ 
  /mx:RemoteObject
   
  mx:DataGrid id=dg dataProvider={resultList} width=838  
  editable=true showHeaders=true
  mx:columns
mx:Array  
  mx:DataGridColumn columnName=firstname 
  headerText=Firstname/
  mx:DataGridColumn columnName=lastname 
  headerText=Lastname/
/mx:Array 
  /mx:columns
  /mx:DataGrid
  
  
  ** This is the situation i'm in now, we're going to develop new 
apps 
  using RIA technology, we don't have time to learn action scripts 
or 
  any other vedor specific scripts. so i'm trying to convince that 
  flex is the best solution, but it looks like flex dev is not 
rapid 
  as what i saw from demo, still lots of manual coding has to be 
done. 
  May be i'm not understanding fully about flex.
  
  So can you guys tell me whether i should use flex or coldfushion 
or 
  ajax with struts as i did before.
   
  Thanks
  
  
  --- In flexcoders@yahoogroups.com, douglowder 
[EMAIL PROTECTED] 
  wrote:
  
   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 flexcoders@yahoogroups.com, sshriyan27 
[EMAIL PROTECTED] 
  wrote:
   
Let me send you all my classes, i don't still understand! 
Thanks 
  for 
your help anyway.
 
public class 

[flexcoders] Re: Java POJO/Action Script question

2006-02-02 Thread douglowder
It isn't a case of need.  One reason you might *want* to have public
members in your POJO is for convenience.  Flex will automatically
handle conversion of Java strings (as well as several other types;
check the documentation) to actionscript, so if your RemoteObject
returns a collection of POJOs with public String members you can plug
that list directly into a grid's dataprovider without any extra
actionscript code.  This would correspond to collections of ClassA and
ClassB objects, which map nicely to what dataProviders expect.  You
cannot, however, pass a list of Class1 POJOs and expect the datagrid
to display Class1.ClassA.A1, Class1.ClassB.B1, etc., without doing
some extra work on the actionscript side.  See the difference?

Now, this doesn't mean you *have* to do things either one way or
another.  I'm just trying to explain what I personally think is the
easiest way to get POJO data into a dataGrid in Flex.  If this still
isn't clear, let me know and I'll try to provide some working code.

Hope that helps!

Doug

--- In flexcoders@yahoogroups.com, sshriyan27 [EMAIL PROTECTED] wrote:

 Thanks guys for helping me out here, but still i don't understand 
 why should i need to have public members firstname,lastname etc in 
 the CloserResultsForm form, isn't it involves redundancy and hard to 
 maintain lots of member variables. 
 
 all i want is this,
 
 Class1 instanciate class A, class B, Class A has member variables 
 A1,A2 and Class B has B1,B2 etc,
 if i want to display A1, B1 values using Class1, 
 i should be saying classA.A1,classA.A2, ClassB.B1, ClassB.B2 etc,
 i don't want to declare A1,A2 in Class1 again in 2 palces.
 Am i missing something here about my design pattern? May be i'm 
 confused.
 Pls help me soon.
 
 --- In flexcoders@yahoogroups.com, douglowder douglowder@ 
 wrote:
 
  You're almost there!  What you want is for CloserDataAccess to 
 return
  a list of objects that contain firstname and lastname properties. 
  What you have now is a list of objects that contain other objects 
 (the
  UserProfileForms), which then contain firstname and lastname.
  
  If your CloserResultsForm java class had public members firstname 
 and
  lastname, initialized by calling the proper getters from
  UserProfileForm, your datagrid should work.  This wouldn't even
  require the separate ActionScript classes for CloserResultsForm and
  UserProfileForm.
  
  
  Doug
  
  
  --- In flexcoders@yahoogroups.com, sshriyan27 [EMAIL PROTECTED] 
 wrote:
  
   Thanks but still not working i made them private now.
   I'm totally lost with action script and object mapping.
   Do i need to use action script for the value objects i have, if 
 that 
   so is there any easy way to write action scripts same as the 
 java 
   objects. 
   
   
   mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml; 
   initialize=initApp() xmlns:i2view=view pageTitle=Test 
   Application
 
mx:Script
 import src.com.flex.form.*;
 
 var users: Array;
 var upForm: UserProfileForm;
 var closerResultsForm: CloserResultsForm;
 var userList: Array;
 var resultList: Array;
 
   function initApp() {
  ro.getResults(); // returns CloserResultsForm as a 
   collection

 }
   
   function getUserList_result(event) {
   userList=event.result;
 }
 
 function getResultList_result(event) {
  resultList=event.result;

   }
  
   
   /mx:Script

mx:RemoteObject id=ro 
   source=com.chl.dataaccess.CloserDataAccess
   mx:method name=getResults result=getResultList_result
   (event)/ 
   /mx:RemoteObject

   mx:DataGrid id=dg dataProvider={resultList} width=838  
   editable=true showHeaders=true
   mx:columns
 mx:Array  
   mx:DataGridColumn columnName=firstname 
   headerText=Firstname/
   mx:DataGridColumn columnName=lastname 
   headerText=Lastname/
 /mx:Array 
 /mx:columns
   /mx:DataGrid
   
   
   ** This is the situation i'm in now, we're going to develop new 
 apps 
   using RIA technology, we don't have time to learn action scripts 
 or 
   any other vedor specific scripts. so i'm trying to convince that 
   flex is the best solution, but it looks like flex dev is not 
 rapid 
   as what i saw from demo, still lots of manual coding has to be 
 done. 
   May be i'm not understanding fully about flex.
   
   So can you guys tell me whether i should use flex or coldfushion 
 or 
   ajax with struts as i did before.

   Thanks
   
   
   --- In flexcoders@yahoogroups.com, douglowder 
 [EMAIL PROTECTED] 
   wrote:
   
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 

[flexcoders] Re: Java POJO/Action Script question

2006-02-02 Thread sshriyan27
Thanks Doug,
Now i understand. Let me ask you a question then, my design consists 
of 2 parts, i have entity objects and dataaccess objects, each time 
i do a method call in dataaccess obj and it returns either a 
collection of entity objects or single entity objects to client.

Is this a right way to do or should i use some facade patterns, what 
do you think, since i'm coming struts background it's kind of 
learning curve for me using flex. I'm not using any EJB's for our 
application. It's a simple 3 tier arch.

thanks




--- In flexcoders@yahoogroups.com, douglowder [EMAIL PROTECTED] 
wrote:

 It isn't a case of need.  One reason you might *want* to have 
public
 members in your POJO is for convenience.  Flex will automatically
 handle conversion of Java strings (as well as several other types;
 check the documentation) to actionscript, so if your RemoteObject
 returns a collection of POJOs with public String members you can 
plug
 that list directly into a grid's dataprovider without any extra
 actionscript code.  This would correspond to collections of ClassA 
and
 ClassB objects, which map nicely to what dataProviders expect.  You
 cannot, however, pass a list of Class1 POJOs and expect the 
datagrid
 to display Class1.ClassA.A1, Class1.ClassB.B1, etc., without doing
 some extra work on the actionscript side.  See the difference?
 
 Now, this doesn't mean you *have* to do things either one way or
 another.  I'm just trying to explain what I personally think is the
 easiest way to get POJO data into a dataGrid in Flex.  If this 
still
 isn't clear, let me know and I'll try to provide some working code.
 
 Hope that helps!
 
 Doug
 
 --- In flexcoders@yahoogroups.com, sshriyan27 sshriyan27@ 
wrote:
 
  Thanks guys for helping me out here, but still i don't 
understand 
  why should i need to have public members firstname,lastname etc 
in 
  the CloserResultsForm form, isn't it involves redundancy and 
hard to 
  maintain lots of member variables. 
  
  all i want is this,
  
  Class1 instanciate class A, class B, Class A has member 
variables 
  A1,A2 and Class B has B1,B2 etc,
  if i want to display A1, B1 values using Class1, 
  i should be saying classA.A1,classA.A2, ClassB.B1, ClassB.B2 etc,
  i don't want to declare A1,A2 in Class1 again in 2 palces.
  Am i missing something here about my design pattern? May be i'm 
  confused.
  Pls help me soon.
  
  --- In flexcoders@yahoogroups.com, douglowder douglowder@ 
  wrote:
  
   You're almost there!  What you want is for CloserDataAccess to 
  return
   a list of objects that contain firstname and lastname 
properties. 
   What you have now is a list of objects that contain other 
objects 
  (the
   UserProfileForms), which then contain firstname and lastname.
   
   If your CloserResultsForm java class had public members 
firstname 
  and
   lastname, initialized by calling the proper getters from
   UserProfileForm, your datagrid should work.  This wouldn't even
   require the separate ActionScript classes for 
CloserResultsForm and
   UserProfileForm.
   
   
   Doug
   
   
   --- In flexcoders@yahoogroups.com, sshriyan27 
[EMAIL PROTECTED] 
  wrote:
   
Thanks but still not working i made them private now.
I'm totally lost with action script and object mapping.
Do i need to use action script for the value objects i have, 
if 
  that 
so is there any easy way to write action scripts same as the 
  java 
objects. 


mx:Application 
xmlns:mx=http://www.macromedia.com/2003/mxml; 
initialize=initApp() xmlns:i2view=view pageTitle=Test 
Application

 mx:Script
  import src.com.flex.form.*;
  
  var users: Array;
  var upForm: UserProfileForm;
  var closerResultsForm: CloserResultsForm;
  var userList: Array;
  var resultList: Array;
  
function initApp() {
 ro.getResults(); // returns 
CloserResultsForm as a 
collection
   
}

function getUserList_result(event) {
userList=event.result;
}

function getResultList_result(event) {
   resultList=event.result;
   
}
 

/mx:Script
 
 mx:RemoteObject id=ro 
source=com.chl.dataaccess.CloserDataAccess
mx:method name=getResults result=getResultList_result
(event)/ 
/mx:RemoteObject
 
mx:DataGrid id=dg dataProvider={resultList} 
width=838  
editable=true showHeaders=true
mx:columns
  mx:Array  
mx:DataGridColumn columnName=firstname 
headerText=Firstname/
mx:DataGridColumn columnName=lastname 
headerText=Lastname/
  /mx:Array 
/mx:columns
/mx:DataGrid


** This is the situation i'm in now, we're going to develop 
new 
  apps 
using RIA 

[flexcoders] Re: Java POJO/Action Script question

2006-02-02 Thread douglowder
I think that design is fine.  I use a similar approach, except that my
POJOs are a combination of entity objects + dataaccess method, i.e.
each class has a getList() method that returns a list of all known
instances of that type.  I chose that approach because these were
POJOs written explicitly with Flex in mind, since this was a new
project with no existing codebase to work from.  It's entirely up to
you how much separation you want between data access and the objects
themselves.

A case where you might be forced to use a facade class is when you
have a private member that is determined dynamically in code and
accessed only through a getter.  In this instance, you could write
another class that calls the first class's getter and sets a public
member variable to the results.  This new class would be what your
RemoteObject calls from Flex.


Doug

--- In flexcoders@yahoogroups.com, sshriyan27 [EMAIL PROTECTED] wrote:

 Thanks Doug,
 Now i understand. Let me ask you a question then, my design consists 
 of 2 parts, i have entity objects and dataaccess objects, each time 
 i do a method call in dataaccess obj and it returns either a 
 collection of entity objects or single entity objects to client.
 
 Is this a right way to do or should i use some facade patterns, what 
 do you think, since i'm coming struts background it's kind of 
 learning curve for me using flex. I'm not using any EJB's for our 
 application. It's a simple 3 tier arch.
 
 thanks
 
 
 
 
 --- In flexcoders@yahoogroups.com, douglowder douglowder@ 
 wrote:
 
  It isn't a case of need.  One reason you might *want* to have 
 public
  members in your POJO is for convenience.  Flex will automatically
  handle conversion of Java strings (as well as several other types;
  check the documentation) to actionscript, so if your RemoteObject
  returns a collection of POJOs with public String members you can 
 plug
  that list directly into a grid's dataprovider without any extra
  actionscript code.  This would correspond to collections of ClassA 
 and
  ClassB objects, which map nicely to what dataProviders expect.  You
  cannot, however, pass a list of Class1 POJOs and expect the 
 datagrid
  to display Class1.ClassA.A1, Class1.ClassB.B1, etc., without doing
  some extra work on the actionscript side.  See the difference?
  
  Now, this doesn't mean you *have* to do things either one way or
  another.  I'm just trying to explain what I personally think is the
  easiest way to get POJO data into a dataGrid in Flex.  If this 
 still
  isn't clear, let me know and I'll try to provide some working code.
  
  Hope that helps!
  
  Doug
  
  --- In flexcoders@yahoogroups.com, sshriyan27 sshriyan27@ 
 wrote:
  
   Thanks guys for helping me out here, but still i don't 
 understand 
   why should i need to have public members firstname,lastname etc 
 in 
   the CloserResultsForm form, isn't it involves redundancy and 
 hard to 
   maintain lots of member variables. 
   
   all i want is this,
   
   Class1 instanciate class A, class B, Class A has member 
 variables 
   A1,A2 and Class B has B1,B2 etc,
   if i want to display A1, B1 values using Class1, 
   i should be saying classA.A1,classA.A2, ClassB.B1, ClassB.B2 etc,
   i don't want to declare A1,A2 in Class1 again in 2 palces.
   Am i missing something here about my design pattern? May be i'm 
   confused.
   Pls help me soon.
   
   --- In flexcoders@yahoogroups.com, douglowder douglowder@ 
   wrote:
   
You're almost there!  What you want is for CloserDataAccess to 
   return
a list of objects that contain firstname and lastname 
 properties. 
What you have now is a list of objects that contain other 
 objects 
   (the
UserProfileForms), which then contain firstname and lastname.

If your CloserResultsForm java class had public members 
 firstname 
   and
lastname, initialized by calling the proper getters from
UserProfileForm, your datagrid should work.  This wouldn't even
require the separate ActionScript classes for 
 CloserResultsForm and
UserProfileForm.


Doug


--- In flexcoders@yahoogroups.com, sshriyan27 
 [EMAIL PROTECTED] 
   wrote:

 Thanks but still not working i made them private now.
 I'm totally lost with action script and object mapping.
 Do i need to use action script for the value objects i have, 
 if 
   that 
 so is there any easy way to write action scripts same as the 
   java 
 objects. 
 
 
 mx:Application 
 xmlns:mx=http://www.macromedia.com/2003/mxml; 
 initialize=initApp() xmlns:i2view=view pageTitle=Test 
 Application
   
  mx:Script
   import src.com.flex.form.*;
   
   var users: Array;
   var upForm: UserProfileForm;
   var closerResultsForm: CloserResultsForm;
   var userList: Array;
   var resultList: Array;
   
 function initApp() {
ro.getResults(); // returns 
 CloserResultsForm as 

Re: [flexcoders] Re: Java POJO/Action Script question

2006-01-24 Thread Anatole Tartakovsky





Other option would be to use free products like 
beanshell to give you access to the local variables - youcould build 
facade class dynamically or just provide "transparency gateway" proxy. The fact 
that you are converting J2EE application indicates that amount of data is not 
significant, so the cost is not going to be an issue, and you can reuse proxy 
for subsequent calls. 
In the end, it would be just a migration support 
excercise, as your current J2EE code will be changing so much, it would not make 
sense to keep the old one - Java interpreter is fine as long as it is not high 
callvolume system.
HTH,
Anatole Tartakovsky


  - Original Message - 
  From: 
  Dave Wolf 
  
  To: flexcoders@yahoogroups.com 
  Sent: Tuesday, January 24, 2006 8:59 
  AM
  Subject: [flexcoders] Re: Java 
  POJO/Action Script question
  Ahh yes, the same J2EE struggles with property 
  setting. As Doug saysyou do not want to be calling a million setters 
  on a remote object.You are better off refactoring this to either create a 
  new ValueObject, or to treat your existing class itself as a value 
  object. So rather then getting a remote reference to say 
  UserProfileForm, thencalling a million getters and setters, I would create 
  a POJO whichreturns the UserProfileForm as a return type. Then call 
  all yoursetters locally, and pass it back up to the server as the 
  parameter toanother POJO method call.The second option is to add a 
  new Value Object property to theUserProfileForm. Again create the 
  stub, call all the setters on thelocal value object, then call one call on 
  the UserProfileForm toreturn this coarsly grained Value Object.You 
  need to keep network calls in mind in your architecture. There isa 
  graveyard filled with failed J2EE projects who ignored the networkand the 
  effects of not architecting around seriously reducing thenumber and size 
  of remote calls.-- Dave WolfCynergy Systems, 
  Inc.Macromedia Flex Alliance Partnerhttp://www.cynergysystems.comEmail: 
  [EMAIL PROTECTED]Office: 866-CYNERGY--- In 
  flexcoders@yahoogroups.com, "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 
  flexcoders@yahoogroups.com, "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








  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  Y

[flexcoders] Re: Java POJO/Action Script question

2006-01-24 Thread sshriyan27
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 flexcoders@yahoogroups.com, 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 flexcoders@yahoogroups.com, 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 flexcoders@yahoogroups.com, 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 

[flexcoders] Re: Java POJO/Action Script question

2006-01-24 Thread douglowder
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 flexcoders@yahoogroups.com, 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 flexcoders@yahoogroups.com, 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 flexcoders@yahoogroups.com, 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 
  

[flexcoders] Re: Java POJO/Action Script question

2006-01-24 Thread sshriyan27
Thanks but still not working i made them private now.
I'm totally lost with action script and object mapping.
Do i need to use action script for the value objects i have, if that 
so is there any easy way to write action scripts same as the java 
objects. 


mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml; 
initialize=initApp() xmlns:i2view=view pageTitle=Test 
Application

 mx:Script
  import src.com.flex.form.*;
  
  var users: Array;
  var upForm: UserProfileForm;
  var closerResultsForm: CloserResultsForm;
  var userList: Array;
  var resultList: Array;
  
function initApp() {
 ro.getResults(); // returns CloserResultsForm as a 
collection
   
}

function getUserList_result(event) {
userList=event.result;
}

function getResultList_result(event) {
   resultList=event.result;
   
}
 

/mx:Script
 
 mx:RemoteObject id=ro 
source=com.chl.dataaccess.CloserDataAccess
mx:method name=getResults result=getResultList_result
(event)/ 
/mx:RemoteObject
 
mx:DataGrid id=dg dataProvider={resultList} width=838  
editable=true showHeaders=true
mx:columns
  mx:Array  
mx:DataGridColumn columnName=firstname 
headerText=Firstname/
mx:DataGridColumn columnName=lastname 
headerText=Lastname/
  /mx:Array 
/mx:columns
/mx:DataGrid


** This is the situation i'm in now, we're going to develop new apps 
using RIA technology, we don't have time to learn action scripts or 
any other vedor specific scripts. so i'm trying to convince that 
flex is the best solution, but it looks like flex dev is not rapid 
as what i saw from demo, still lots of manual coding has to be done. 
May be i'm not understanding fully about flex.

So can you guys tell me whether i should use flex or coldfushion or 
ajax with struts as i did before.
 
Thanks


--- In flexcoders@yahoogroups.com, douglowder [EMAIL PROTECTED] 
wrote:

 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 flexcoders@yahoogroups.com, 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 

[flexcoders] Re: Java POJO/Action Script question

2006-01-24 Thread douglowder
You're almost there!  What you want is for CloserDataAccess to return
a list of objects that contain firstname and lastname properties. 
What you have now is a list of objects that contain other objects (the
UserProfileForms), which then contain firstname and lastname.

If your CloserResultsForm java class had public members firstname and
lastname, initialized by calling the proper getters from
UserProfileForm, your datagrid should work.  This wouldn't even
require the separate ActionScript classes for CloserResultsForm and
UserProfileForm.


Doug


--- In flexcoders@yahoogroups.com, sshriyan27 [EMAIL PROTECTED] wrote:

 Thanks but still not working i made them private now.
 I'm totally lost with action script and object mapping.
 Do i need to use action script for the value objects i have, if that 
 so is there any easy way to write action scripts same as the java 
 objects. 
 
 
 mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml; 
 initialize=initApp() xmlns:i2view=view pageTitle=Test 
 Application
   
  mx:Script
   import src.com.flex.form.*;
   
   var users: Array;
   var upForm: UserProfileForm;
   var closerResultsForm: CloserResultsForm;
   var userList: Array;
   var resultList: Array;
   
 function initApp() {
ro.getResults(); // returns CloserResultsForm as a 
 collection
  
   }
 
 function getUserList_result(event) {
 userList=event.result;
   }
   
   function getResultList_result(event) {
resultList=event.result;
  
 }

 
 /mx:Script
  
  mx:RemoteObject id=ro 
 source=com.chl.dataaccess.CloserDataAccess
 mx:method name=getResults result=getResultList_result
 (event)/ 
 /mx:RemoteObject
  
 mx:DataGrid id=dg dataProvider={resultList} width=838  
 editable=true showHeaders=true
 mx:columns
   mx:Array  
 mx:DataGridColumn columnName=firstname 
 headerText=Firstname/
 mx:DataGridColumn columnName=lastname 
 headerText=Lastname/
   /mx:Array 
   /mx:columns
 /mx:DataGrid
 
 
 ** This is the situation i'm in now, we're going to develop new apps 
 using RIA technology, we don't have time to learn action scripts or 
 any other vedor specific scripts. so i'm trying to convince that 
 flex is the best solution, but it looks like flex dev is not rapid 
 as what i saw from demo, still lots of manual coding has to be done. 
 May be i'm not understanding fully about flex.
 
 So can you guys tell me whether i should use flex or coldfushion or 
 ajax with struts as i did before.
  
 Thanks
 
 
 --- In flexcoders@yahoogroups.com, douglowder [EMAIL PROTECTED] 
 wrote:
 
  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 flexcoders@yahoogroups.com, 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 

[flexcoders] Re: Java POJO/Action Script question

2006-01-23 Thread douglowder
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 flexcoders@yahoogroups.com, 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/