The Level-1 nodes (I suppose you the mean below the root node) can not be refreshed the way you are doing it.
The Level-1 nodes (I suppose you the mean below the root node) can not be refreshed the way you are doing it. You have to store the instance of your dataProvider for the level-1 nodes somewhere. Later when you refresh your list you have to update your stored dataProvider for your level-1 nodes.
The nodes below the level-1 can be refreshed the way you are doing it. Because as soon as you close the level 1 nodes (that is what you are doing in the updateTree method) and the next time you open it getNodeInfo will be called and the updated Subcategories will be retrieved and displayed in the CellTree. UPDATE For refreshing the CellWidgets which is attached to AsyncDataProvider you will probably have to extend the AsyncDataProvider and either extract the RPC call to a getData() method which is called in the onRangeChanged() method or create an interface with a refresh method and implement it in your custom AsyncDataProvider which calls the protected onRangeChanged() method.
Good! ^___^ but... HOW?!? -.
-' I mean, the only method available on the provider is updateRowData(), do I have to duplicate the rpc code present in onRangeChanged(), or can I simply trigger the "range changed" event in some way? Thanks – Fabio B. Aug 31 at 12:37 see my updated answer – Ümit Aug 31 at 13:02.
Working example. Add reference to DataProvider (and parent Node) (MyMenuItem and MyCell with DataProvider in my code). After adding element refresh parent.
Public class MyMenuItem { private String name; private String action; //some data private int level; //if needed private ArrayList list; //nodes childrens private MyMenuItem parent; //track internal parent private MyCell cell; //for refresh - reference to visual component public void setCell(MyCell cell) { this. Cell = cell; } public void refresh() { if(parent! =null) { parent.refresh(); } if (cell!
=null) { cell.refresh(); //refresh tree } } public String getName() { return name; } public void setName(String name) { this. Name = name; } public String getAction() { return action; } public void setAction(String action) { this. Action = action; } public MyMenuItem(String name, String action) { super(); parent = null; level = 0; this.Name = name; this.
Action = action; list = new ArrayList(); } public MyMenuItem(String name) { this(name, ""); } public void addSubMenu(MyMenuItem m) { m. Level = this. Level+1; m.
Parent = this; list. Add(m); } public boolean hasChildrens() { return list.size()>0; } public int getLevel() { return level; } public void setLevel(int level) { this. Level = level; } public ArrayList getList() { return list; } public MyMenuItem getParent() { return parent; } } public class MyTreeModel implements TreeViewModel { private MyMenuItem officialRoot; //default not dynamic private MyMenuItem studentRoot; //default not dynamic private MyMenuItem testRoot; //default not dynamic private MyMenuItem root; public MyMenuItem getRoot() { // to set CellTree root return root; } public MyTreeModel() { root = new MyMenuItem("root"); // Default items officialRoot = new MyMenuItem("Official"); //some basic static data studentRoot = new MyMenuItem("Student"); testRoot = new MyMenuItem("Test"); root.
AddSubMenu(officialRoot); root. AddSubMenu(studentRoot); root. AddSubMenu(testRoot); } //example of add add logic private void addNew(MyMenuItem myparent, String name, String uid) { myparent.
AddSubMenu(new MyMenuItem(name, uid)); myparent.refresh(); //HERE refresh tree } @Override public NodeInfo getNodeInfo(T value) { ListDataProvider dataProvider; MyMenuItem myValue = null; if (value == null) { // root is not set dataProvider = new ListDataProvider(root.getList()); } else { myValue = (MyMenuItem) value; dataProvider = new ListDataProvider(myValue.getList()); } MyCell cell = new MyCell(dataProvider); //HERE Add reference if (myValue! = null) myValue. SetCell(cell); return new DefaultNodeInfo(dataProvider, cell); } @Override public boolean isLeaf(Object value) { if (value instanceof MyMenuItem) { MyMenuItem t = (MyMenuItem) value; if (!t.hasChildrens()) return true; return false; } return false; } } public class MyCell extends AbstractCell { ListDataProvider dataProvider; //for refresh public MyCell(ListDataProvider dataProvider) { super("keydown","dblclick"); this.
DataProvider = dataProvider; } public void refresh() { dataProvider.refresh(); } @Override public void onBrowserEvent(Context context, Element parent, MyMenuItem value, NativeEvent event, ValueUpdater valueUpdater) { if (value == null) { return; } super. OnBrowserEvent(context, parent, value, event, valueUpdater); if ("click". Equals(event.getType())) { this.
OnEnterKeyDown(context, parent, value, event, valueUpdater); } if ("dblclick". Equals(event.getType())) { this. OnEnterKeyDown(context, parent, value, event, valueUpdater); } } @Override public void render(Context context, MyMenuItem value, SafeHtmlBuilder sb) { if (value == null) { return; } sb.
AppendEscaped(value.getName()); //add HERE for better formating } @Override protected void onEnterKeyDown(Context context, Element parent, MyMenuItem value, NativeEvent event, ValueUpdater valueUpdater) { Window. Alert("You clicked "+event.getType()+" " + value.getName()); } } in module add treeModel = new MyTreeModel(); tree = new CellTree(treeModel,treeModel.getRoot()).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.