Re: [flexcoders] arraycollection and tree

2008-03-25 Thread Nayan Savla

Hi Luke,

Just create a List in Java and return it. alternatively you can add it  
to a Value Object and then return it. below is example of my function,  
CategoriesVo is simple java class with three public variables.


public List getCategoriesAll(){
List list = new ArrayList();

		String query = SELECT main.id, main.name, sub.name FROM  
maincategories AS main, subcategories AS sub WHERE main.id =  
sub.maincategoryId;

//String query = SELECT * FROM maincategories;

try {
ResultSet results = 
connManager.stmt.executeQuery(query);
//results.first();

String secondKey = ;
String firstKey = ;

Integer categoryId;
while (results.next()){
CategoriesVo categories = new CategoriesVo();
firstKey = results.getString(2);
categoryId = results.getInt(1);
secondKey = results.getString(3);

categories.mainCategory = secondKey;
categories.subCategories = firstKey;

categories.categoryId = prevCategory;

list.add(categories);
// hashMap.put(secondKey, list);
// System.out.println(adding to the hashmap 
 + secondKey);

}
} catch (SQLException e){   
}   

return list;
}


this can be cast to arraycollection in Flex or you can loop through  
the result and add it to a collection.


hope this helps.

Nayan


On Mar 24, 2008, at 10:57 PM, Luke Vanderfluit wrote:


Hi.

I am using remoteobject to get stuff from a database (java/mysql). I
want to represent the List, generated on the server side and sent to  
the

client as an arraycollection, as a tree.

Does anyone have examples of how to do this.
I have been reading the online docs but Im making very slow progress.

Thanks.
Kind regards.
Luke.






[flexcoders] arraycollection and tree

2008-03-24 Thread Luke Vanderfluit
Hi.

I am using remoteobject to get stuff from a database (java/mysql). I 
want to represent the List, generated on the server side and sent to the 
client as an arraycollection, as a tree.

Does anyone have examples of how to do this.
I have been reading the online docs but Im making very slow progress.

Thanks.
Kind regards.
Luke.