Package org.codehaus.mojo.gwt.test.client

Source Code of org.codehaus.mojo.gwt.test.client.Hello

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/

// START SNIPPET: hello-class
package org.codehaus.mojo.gwt.test.client;

import org.codehaus.mojo.gwt.test.domain.User;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;

public class Hello
    implements EntryPoint
{
    final HelloServiceAsync service = HelloServiceAsync.Util.getInstance();

    public void onModuleLoad()
    {
        User user = new User();
        final Label l = new Label( "GWT says : " + user.sayHello() );
        RootPanel.get().add( l );

        Button b = new Button( "click me !" );
        RootPanel.get().add( b );
        b.addClickHandler( new ClickHandler()
        {
            public void onClick( ClickEvent event )
            {
                service.sayHello( "hello", new AsyncCallback<String>()
                {

                    public void onFailure( Throwable caught )
                    {
                        l.setText( "RPC failure " + caught.getMessage() );
                        GWT.log( "RPC failure", caught );
                    }

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

    }
}
// END SNIPPET: hello-class
TOP

Related Classes of org.codehaus.mojo.gwt.test.client.Hello

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.