From: Kay Krüger-B. <ka...@we...> - 2008-10-07 08:04:16
|
Hi, the problem is the refresh attribute. Admittedly, its name does imply that it refreshes the content of the tree. But it does not. It only refreshes the node representations of the current tree structure, i.e. it uses the value attribute for each node to requery its node text. So "refresh" is used, for example, if your application allows different settings of what to display for each node in the tree and when the user changes this setting you fire the corresponding event so the new node display settings are reflected in the GUI. (see also documentation of refresh attribute: http://www.gui4j.org/gui4jdocs/tree.html) Anyway, what you need is to simply make your root attribute "event aware" (see http://www.gui4j.org/gui4jdocs/events.html). So instead of <tree root="getTreeRoot" guiId="tree" refresh="{eSwitch}"> you write <tree root="{eSwitch}getTreeRoot" guiId="tree"> That should do the trick. As a side note, I think your datastructure for the tree is a bit strange. When adding a new project you add it to a list of projects and this list then defines the children of the same project. So you'll end up with a recursive tree where each project is a child of itself. Hope it helps, Kay > -----Ursprüngliche Nachricht----- > Von: "Linu Hila" <lin...@ya...> > Gesendet: 04.10.08 22:19:10 > An: gui...@li... > Betreff: [Gui4j-user] refresh tree > > > Hello > I am having some troubles with the graphic appearence of a tree. > Each node is populated by a list > When trying to add a new node from a menu command, i add an Object > to a list and also i fire an event. > Then i add the refresh element to the tree ,and add an event to be > aware, like here > > <tree root="getTreeRoot" guiId="tree" refresh="{eSwitch}"> > <node value="'Root'" contentType="Root" > onSelect="actionSelectRoot(?item)" > children="getChildrenOfRoot(?item)" /> > ... > <node value="?item.getNodeText" contentType="Project" > onSelect="actionSelectPrj(?item)" children="?item.getChildren" /> > ... > </tree> > > From the menu i call the newPrj function of the controller like this > <menuBar guiId="menuBar"> > <menu text="'File'"> > <menu text="'New'"> > <menuItem text = "'Project'" actionCommand = "newPrj"></menuItem> > and newPrj function triggers an event after adding another element to > the project list > > public void addPrj() { > Project p = new Project("New Project"); > prjList.add(p); > p.setChildren(prjList); > eSwitch.fireEvent(); > } > I can see the list is added a new element,but no graphic node is " > drawn" in the tree, even if i call refresh attribute of the tree. > What do i do wrong? > Thank you > > --------------------------------------------------------------------- > ---- This SF.Net email is sponsored by the Moblin Your Move Developer' > s challenge Build the coolest Linux based applications with Moblin > SDK & win great prizes Grand prize is a trip for two to an Open > Source event anywhere in the world http://moblin-contest.org/redirect. > php?banner_id=100&url=/ _____________________________________________ > __ Gui4j-user mailing list Gui...@li... https:// > > lists.sourceforge.net/lists/listinfo/gui4j-user _________________________________________________________________________ In 5 Schritten zur eigenen Homepage. Jetzt Domain sichern und gestalten! Nur 3,99 EUR/Monat! http://www.maildomain.web.de/?mc=021114 |