As I said in reply to your precedent message, you can add "userObject" to a
tree item, which is every class you want :

http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/TreeItem.html#setUserObject(java.lang.Object)

2009/2/9 Raju <[email protected]>

>
> I am new to gwt .I am using gwt tree ,when click the treeitem i am
> getting treeitem text ...but I need to get multiple values like (code,
> name ,parentcode).(how to set multiple values to TreeItem)
>
> Any one can help me..
>
>
> here my code:
>
> /*
>  * TreeMainEntryPoint.java
>  *
>  * Created on February 5, 2009, 2:36 PM
>  *
>  * To change this template, choose Tools | Template Manager
>  * and open the template in the editor.
>  */
> package org.karishma.client;
>
> import com.google.gwt.core.client.EntryPoint;
> import com.google.gwt.core.client.GWT;
> import com.google.gwt.user.client.Window;
> import com.google.gwt.user.client.rpc.AsyncCallback;
> import com.google.gwt.user.client.rpc.ServiceDefTarget;
>
> import com.google.gwt.user.client.ui.RootPanel;
> import com.google.gwt.user.client.ui.Tree;
> import com.google.gwt.user.client.ui.TreeItem;
> import com.google.gwt.user.client.ui.TreeListener;
> import com.google.gwt.user.client.ui.Widget;
> import com.gwtext.client.widgets.Panel;
>
> import com.gwtext.client.widgets.tree.TreeNode;
> import java.util.ArrayList;
> import java.util.Iterator;
> import java.util.ListIterator;
>
> /**
>  *
>  * @author veerraju
>  */
> public class TreeMainEntryPoint extends Tree implements EntryPoint,
> TreeListener {
>
>    public Tree tree;
>
>    /**
>    The entry point method, called automatically by loading a module
>    that declares an implementing class as an entry-point
>     */
>    public void onModuleLoad() {
>        tree = new Tree();
>        tree.addTreeListener((TreeListener) this);
>        tree.setWidth("10px");
>        Panel p1 = new Panel();
>        p1.add(tree);
>        p1.setTitle("Tree Structure");
>        p1.setBorder(true);
>        p1.setPaddings(5);
>        p1.setSize(250, 500);
>        p1.setAutoScroll(true);
>        RootPanel.get().add(p1);
>        // Create an asynchronous callback to handle the result.
>        final AsyncCallback callback = new AsyncCallback() {
>
>            public void onSuccess(Object result) {
>                ArrayList pal1 = (ArrayList) result;
>                ListIterator li1 = pal1.listIterator();
>                while (li1.hasNext()) {
>                    String code = (String) li1.next();
>                    String name = (String) li1.next();
>                    String parent = (String) li1.next();
>
>                    if (parent.equals("")) {
>                        String count = getChildCount(pal1, code);
>                        //Window.alert(count);
>                        if (Integer.parseInt(count) > 0) {
>                            TreeItem i1 = new TreeItem(name);
>                            // Window.alert(name);
>
>                            getSubNodes(i1, pal1, code);
>                            tree.addItem(i1);
>                        } else {
>                            tree.addItem(name);
>                        }
>                    }
>                }
>            }
>
>            public void onFailure(Throwable caught) {
>                Window.alert("Communication failed....");
>            }
>
>            public String getChildCount(ArrayList a, String parent) {
>                int i = 0;
>                Iterator j = a.iterator();
>                while (j.hasNext()) {
>                    String code = (String) j.next();
>                    String name = (String) j.next();
>                    String parent1 = (String) j.next();
>                    if (parent1.equals(parent)) {
>                        i = i + 1;
>                    }
>                }
>
>                return new Integer(i).toString();
>            }
>
>            public void getSubNodes(TreeItem i1, ArrayList a, String
> parent) {
>
>                ListIterator j = a.listIterator();
>                while (j.hasNext()) {
>                    String code = (String) j.next();
>                    String name = (String) j.next();
>                    String parent1 = (String) j.next();
>                    if (parent1.equals(parent)) {
>                        String count = getChildCount(a, code);
>                        if (Integer.parseInt(count) > 0) {
>                            TreeNode node1 = new TreeNode(name, code);
>                            TreeItem i2 = new TreeItem(node1.getText
> ());
>                            // Window.alert(i2.toString());
>                            getSubNodes(i2, a, code);
>                            i1.addItem(i2);
>                        } else {
>                            i1.addItem(name);
>                        }
>                    }
>                }
>
>            }
>        };
>        getService().getTree(callback);
>
>    }
>
>    public void onTreeItemSelected(TreeItem i1) {
>
>    Window.alert(i1.getText());
>
>    }
>
>    public void onTreeItemStateChanged(TreeItem i1) {
>        Window.alert("state changed");
>    }
>
>    public static TreeServiceAsync getService() {
>        // Create the client proxy. Note that although you are
> creating the
>        // service interface proper, you cast the result to the
> asynchronous
>        // version of
>        // the interface. The cast is always safe because the
> generated proxy
>        // implements the asynchronous interface automatically.
>        TreeServiceAsync service = (TreeServiceAsync) GWT.create
> (TreeService.class);
>        // Specify the URL at which our service implementation is
> running.
>        // Note that the target URL must reside on the same domain and
> port from
>        // which the host page was served.
>        //
>        ServiceDefTarget endpoint = (ServiceDefTarget) service;
>        String moduleRelativeURL = GWT.getModuleBaseURL() +
> "treeservice";
>        endpoint.setServiceEntryPoint(moduleRelativeURL);
>        return service;
>    }
> }
>
>
> thanks in advance..
> Raju...
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to