user6450105
user6450105

Reputation:

Tree widget shows only one value from list (GWT)

I am working on GWT app and I am using com.google.gwt.user.client.ui.Tree; and com.google.gwt.user.client.ui.TreeItem; widgets to show all GwtDomain objects from my RPC method. And every GwtDomain has some GwtActions values(in most cases that are read, write, delete but not in every case). This is my method for finding all GwtDomains and in his onSuccess methods I am looking for all GwtActions for that GwtDomain:

     GWT_DOMAIN_SERVICE.findAll(new AsyncCallback<List<GwtDomain>>() {

                @Override
                public void onFailure(Throwable caught) {
                    exitMessage = MSGS.dialogAddPermissionErrorDomains(caught.getLocalizedMessage());
                    exitStatus = false;
                    hide();
                }

                @Override
                public void onSuccess(List<GwtDomain> result) {



                    for (final GwtDomain gwtDomain : result) {
                        GWT_DOMAIN_SERVICE.findActionsByDomainName(gwtDomain.name(), new AsyncCallback<List<GwtAction>>() {

                            @Override
                            public void onFailure(Throwable caught) {
                                exitMessage = MSGS.dialogAddPermissionErrorActions(caught.getLocalizedMessage());
                                exitStatus = false;
                                hide();
                            }

                            @Override
                            public void onSuccess(List<GwtAction> result) {

                                for (GwtAction gwtAction : result) {
                                rootCheckBox= new CheckBox();
                                rootCheckBox.setBoxLabel(gwtDomain.toString());
                                    treeItemCheckox = new CheckBox();

                                    rootTreeItem = new TreeItem(rootCheckBox);
                                    treeItem =  new TreeItem(treeItemCheckox);
                                    treeItemCheckox.setBoxLabel(gwtAction.toString());
                                    rootTreeItem.addItem(treeItem);

                                }
                                tree.addItem(rootTreeItem);

   }
                    });

}

But with this code, I always have just one value from GwtAction not all values(in most cases that should be 3 items for each treeItem2). Could someone helps me?

Upvotes: 0

Views: 65

Answers (1)

Mohamed Bathaoui
Mohamed Bathaoui

Reputation: 340

It's normal. The code tree.addItem(rootTreeItem); is outside the for loop. It must be inside! Regards

Upvotes: 1

Related Questions