Flex Object Tree

Apr 24, 2009

I am sure you will run in to something like this if you are going to work on Flex for your next 4-5 projects. Luckily \ Un-luckily I ran in to this on my first project itself. This was definitely very complex to me when I started but it does make sense after I finish it. Given the complexity of this I will update it iteratively.

Requirement

  • You have a Database table(s) whose data translate to something like Tree with top level is identified using separate column something like ‘isTopLevel’

Assumptions

  • You will have 2 Database tables. One is “FolderVO” and other is “FileVO“. These two tables are linked using 3rd table called “Folder_File_Link
  • FolderVO will have a column to specify ‘isTopLevel’ which will be populated for only top Folder in the tree
  • “Folder_File_Link” will have its structure something like following to identify each folder’s children

    linked        folderId        folder_file_Id    

  • A Folder can have either Folder or File list as its Children based on its property “folderLink” which take “Folder” or “File
  • This structure can be in some other formats too and purpose of this post is just to show how to develop Flex screens to handle something like this

Explanation

On the server side retrieve Folder with ‘isTopLevel‘ is set to ‘T‘ and go to link table and get all the Folders and Files attached to it. This is a recursive method at the end t will generate “FolderVO” object which will have following properties:

public var folderId:int;

public var folderName:String;

public var folderCode:String;

public var folderDescription:String;

public var folderLink:String;    //—- This will identify whether this folder can have Folder or Files as Children

public var topFolder:String;

public var children:ArrayCollection; //—- This contains FolderVO or FileVO objects    recursively    

Here children is a Collection which contains Folders or Clients based on its property ‘folderLink

This Tree will support following features:

  1. Create a Folder (either top level or any children)
  2. Remove Folder
  3. Attach any existing Files
  4. Remove any File from the Folder

**** Given the complexity of this form I will try to add details n next few days or weeks (depending on my schedule). But if you ran in to something like this and need any help drop me a message I will definitely help on this as I went through this pain already J

5 Total TweetBacks: (Tweet this post)
  • en: Hmm, maybe another mini party tomorrow. Chobots or Club Penguin? 07/14/09 05:33am
  • en: @SexiSweets Anyone here use FaceBook or MySpace, are they cool? What about WordPress? YouTube seems cool to me :) I love vids & pics 07/14/09 05:33am
  • en: #GoodSex had you sneakin out of ur house or sneakin into someone house when you were younger..lol 07/14/09 05:33am
  • en: @JIDF or maybe we could come up w/ something uniqie, i designed a possible pin online, $5... the $3 profit go the shalits? 07/14/09 05:33am
  • en: Madd Records Presents Hot or not Wendesday come out and support! San Diego's finest artist, Coming soon Madd tv presented by Madd Records 07/14/09 05:33am
Share and Enjoy:
  • del.icio.us
  • TwitThis
  • LinkedIn
  • StumbleUpon
  • Facebook
  • Google
Posted by Srinivas Kusunam | Categories: Flex |

Share with others

No Responses so far | Have Your Say!

Leave a Feedback

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>