ha,
I am very new to GWT.When doing my application I need add to listener
to my tree .But I am unable to do this .
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.gwtext.client.widgets.Panel;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.ListIterator;
/**
*
* @author veerraju
*/
public class TreeMainEntryPoint implements EntryPoint {
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.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)
{
TreeItem i2=new TreeItem(name);
Window.alert(i2.toString());
getSubNodes(i2,a,code);
i1.addItem(i2);
}
else
{
i1.addItem(name);
}
}
}
}
};
getService().getTree(callback);
}
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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---