📄 test.java
字号:
/******************************************************************************* * Copyright (c) 2005, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/package com.pjaol.client;import com.google.gwt.core.client.EntryPoint;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.Button;import com.google.gwt.user.client.ui.ClickListener;import com.google.gwt.user.client.ui.Label;import com.google.gwt.user.client.ui.RootPanel;import com.google.gwt.user.client.ui.Widget;/** * Entry point classes define <code>onModuleLoad()</code>. */public class test implements EntryPoint { /** * This is the entry point method. */ public void onModuleLoad() { final Button button = new Button("Click me"); final Label label = new Label(); button.addClickListener(new ClickListener() { public void onClick(Widget sender) { if (label.getText().equals("")) //label.setText("Hello World!"); getMyId("fish food", label); else label.setText(""); } }); // Assume that the host HTML has elements defined whose // IDs are "slot1", "slot2". In a real app, you probably would not want // to hard-code IDs. Instead, you could, for example, search for all // elements with a particular CSS class and replace them with widgets. // RootPanel.get("slot1").add(button); RootPanel.get("slot2").add(label); } public void getMyId (String s , final Label label) { TestGWTAsync service = (TestGWTAsync) GWT.create(TestGWT.class); ServiceDefTarget endPoint = (ServiceDefTarget)service; String moduleRelativeURL = GWT.getModuleBaseURL() + "/testGWT"; endPoint.setServiceEntryPoint(moduleRelativeURL); AsyncCallback callback = new AsyncCallback() { public void onSuccess(Object result) { label.setText((String) result); } public void onFailure(Throwable caught) { label.setText("nope :-("); } }; service.getReturnId("fish food", callback); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -