View Full Version : Creating a BaseTreeModel class, static int ID field?
18 Sep 2011, 2:29 PM
Everything in the BaseTreeModel example of the Folder class in the Music example from the Explorer demo page makes sense to me however I am wonder what the ID field is used for? Every single Tree example I have found shows the same thing, to create a Folder class that has a static int ID. What is this for?
19 Sep 2011, 4:11 PM
Static fields are used to share the field across all instances of that type, with the same virtual machine (either jvm on the server, or that running instance of the app in the client browser). This is used as a simple way of telling the difference between instances.
In a real app, rather than an example, your server would likely generate unique ID fields for each instance (notice that each folder instance has a getID() method to see which folder that is). This is often done by letting your database generated ids, for example.
Powered by vBulletin® Version 4.1.5 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.