views:

49

answers:

2

i am writing server example from this site

http://netbeans.org/kb/docs/web/quickstart-webapps-gwt.html

i have following code in main project

import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.core.client.GWT;

import com.google.gwt.user.client.rpc.AsyncCallback;

import com.google.gwt.user.client.rpc.ServiceDefTarget;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;

public class GWTServiceUsageExample extends VerticalPanel{

private Label  lblServerReply=new Label();
private TextBox txtUserInput=new TextBox();
private Button btnSend=new Button("send to server");
public  GWTServiceUsageExample(){

    add(new Label("input your text"));
    add(txtUserInput);
    add(btnSend);
    add(lblServerReply);
    //Create  an  asynchronous callback to handle  the result.
    final AsyncCallback<String>callback=new AsyncCallback<String>(){

            public void onSuccess(String result) {
                lblServerReply.setText(result);
            }

            public void onFailure(Throwable caught) {
                lblServerReply.setText("Communication failed");
            }
        };
        btnSend.addClickHandler((new ClickHandler(){

           public void onClick(ClickEvent event){

               getService().myMethod(txtUserInput.getText(),callback);
           }

        } );
    }
public static GWTServiceAsync getService(){
    return GWT.create((GWTService.class));

    }

}

also in mainentrypoint package

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.davit.client.sampleservice;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * Main entry point.
 *
 * @author David
 */
public class MainEntryPoint implements EntryPoint {
    /** 
     * Creates a new instance of MainEntryPoint
     */
    public MainEntryPoint() {
    }

    /** 
     * The entry point method, called automatically by loading a module
     * that declares an implementing class as an entry-point
     */
    public void onModuleLoad() {


      RootPanel.get().add(new GWTServiceUsageExample());


    }
}

after change my code because i have missed ) i have following errors

init:
deps-module-jar:
deps-ear-jar:
deps-jar:
library-inclusion-in-archive:
library-inclusion-in-manifest:
Compiling 2 source files to C:\Users\David\Documents\NetBeansProjects\GWTServiceUsageExample\build\web\WEB-INF\classes
C:\Users\David\Documents\NetBeansProjects\GWTServiceUsageExample\src\java\GWTServiceUsageExample.java:47: cannot find symbol
symbol  : class GWTServiceAsync
location: class GWTServiceUsageExample
public static GWTServiceAsync getService(){
C:\Users\David\Documents\NetBeansProjects\GWTServiceUsageExample\src\java\GWTServiceUsageExample.java:48: cannot find symbol
symbol  : class GWTService
location: class GWTServiceUsageExample
    return GWT.create((GWTService.class));
C:\Users\David\Documents\NetBeansProjects\GWTServiceUsageExample\src\java\GWTServiceUsageExample.java:48: illegal start of type
    return GWT.create((GWTService.class));
C:\Users\David\Documents\NetBeansProjects\GWTServiceUsageExample\src\java\org\davit\client\sampleservice\MainEntryPoint.java:38: cannot find symbol
symbol  : class GWTServiceUsageExample
location: class org.davit.client.sampleservice.MainEntryPoint
      RootPanel.get().add(new GWTServiceUsageExample());
4 errors
C:\Users\David\Documents\NetBeansProjects\GWTServiceUsageExample\nbproject\build-impl.xml:518: The following error occurred while executing this line:
C:\Users\David\Documents\NetBeansProjects\GWTServiceUsageExample\nbproject\build-impl.xml:248: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)
A: 

In GWTServiceUsageExample.java, you have an extra ( here:

btnSend.addClickHandler((new ClickHandler(){

It should be:

btnSend.addClickHandler(new ClickHandler(){
BoltClock
Whoa, where did the downvote come from?
BoltClock
I don't know, but it wasn't deserved; have an upvote!
EnderMB
@EnderMB: aw, thanks! :)
BoltClock
A: 

Change: btnSend.addClickHandler((new ClickHandler(){ to btnSend.addClickHandler(new ClickHandler(){

Basically take out one unneeded bracket

Maksim
thanks very much after thange i have following problem please help in site which i have post is written that make import of GetServicAsync but in my code only one is option create class GetServiceAsync why?