gpt4 book ai didi

java - GWT 设计器不起作用

转载 作者:行者123 更新时间:2023-12-02 04:48:36 24 4
gpt4 key购买 nike

我正在使用:

Eclipse 开普勒 4.3JDK 7GWT 兼容 eclipse 4.3(通过市场下载)GWT版本是通过GWT市场下载的,默认为2.6.0在eclipse上java编译器版本是1.7这不是一个 Maven 项目

当我尝试打开 GWT EntryPoint 类(即 UI)时,它会抛出以下错误:

EntryPoint 类(创建新 GWT 项目时由 eclipse 默认创建的类):

package xsdf.com.client;

import xsdf.com.shared.FieldVerifier;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Xxwa implements EntryPoint {
/**
* The message displayed to the user when the server cannot be reached or
* returns an error.
*/
private static final String SERVER_ERROR = "An error occurred while "
+ "attempting to contact the server. Please check your network "
+ "connection and try again.";

/**
* Create a remote service proxy to talk to the server-side Greeting service.
*/
private final GreetingServiceAsync greetingService = GWT
.create(GreetingService.class);

/**
* This is the entry point method.
*/
public void onModuleLoad() {
final Button sendButton = new Button("Send");
final TextBox nameField = new TextBox();
nameField.setText("GWT User");
final Label errorLabel = new Label();

// We can add style names to widgets
sendButton.addStyleName("sendButton");

// Add the nameField and sendButton to the RootPanel
// Use RootPanel.get() to get the entire body element
RootPanel.get("nameFieldContainer").add(nameField);
RootPanel.get("sendButtonContainer").add(sendButton);
RootPanel.get("errorLabelContainer").add(errorLabel);

// Focus the cursor on the name field when the app loads
nameField.setFocus(true);
nameField.selectAll();

// Create the popup dialog box
final DialogBox dialogBox = new DialogBox();
dialogBox.setText("Remote Procedure Call");
dialogBox.setAnimationEnabled(true);
final Button closeButton = new Button("Close");
// We can set the id of a widget by accessing its Element
closeButton.getElement().setId("closeButton");
final Label textToServerLabel = new Label();
final HTML serverResponseLabel = new HTML();
VerticalPanel dialogVPanel = new VerticalPanel();
dialogVPanel.addStyleName("dialogVPanel");
dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
dialogVPanel.add(textToServerLabel);
dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
dialogVPanel.add(serverResponseLabel);
dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
dialogVPanel.add(closeButton);
dialogBox.setWidget(dialogVPanel);

// Add a handler to close the DialogBox
closeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
dialogBox.hide();
sendButton.setEnabled(true);
sendButton.setFocus(true);
}
});

// Create a handler for the sendButton and nameField
class MyHandler implements ClickHandler, KeyUpHandler {
/**
* Fired when the user clicks on the sendButton.
*/
public void onClick(ClickEvent event) {
sendNameToServer();
}

/**
* Fired when the user types in the nameField.
*/
public void onKeyUp(KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
sendNameToServer();
}
}

/**
* Send the name from the nameField to the server and wait for a response.
*/
private void sendNameToServer() {
// First, we validate the input.
errorLabel.setText("");
String textToServer = nameField.getText();
if (!FieldVerifier.isValidName(textToServer)) {
errorLabel.setText("Please enter at least four characters");
return;
}

// Then, we send the input to the server.
sendButton.setEnabled(false);
textToServerLabel.setText(textToServer);
serverResponseLabel.setText("");
greetingService.greetServer(textToServer,
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
// Show the RPC error message to the user
dialogBox
.setText("Remote Procedure Call - Failure");
serverResponseLabel
.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(SERVER_ERROR);
dialogBox.center();
closeButton.setFocus(true);
}

public void onSuccess(String result) {
dialogBox.setText("Remote Procedure Call");
serverResponseLabel
.removeStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(result);
dialogBox.center();
closeButton.setFocus(true);
}
});
}
}

// Add a handler to send the name to the server
MyHandler handler = new MyHandler();
sendButton.addClickHandler(handler);
nameField.addKeyUpHandler(handler);
}
}

当我尝试使用GWT Designer打开上述类时出现错误:

 Internal Error
encountered unexpected internal error.

This could be caused by a bug or by a misconfiguration issue, conflict, partial update, etc.

java.lang.NoSuchMethodError: com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(Lcom/google/gwt/core/ext/TreeLogger;Ljava/lang/String;Z)Lcom/google/gwt/dev/cfg/ModuleDef;



Show stack trace.
Hide stack trace.

Stack trace:
java.lang.NoSuchMethodError: com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(Lcom/google/gwt/core/ext/TreeLogger;Ljava/lang/String;Z)Lcom/google/gwt/dev/cfg/ModuleDef;
at com.google.gwt.dev.shell.designtime.HostedModeSupportImpl.loadModule(HostedModeSupportImpl.java:85)
at com.google.gwt.dev.shell.designtime.HostedModeSupportImpl.createModuleSpaceHost(HostedModeSupportImpl.java:64)
at sun.reflect.NativeMetho

我已经检查了可能存在的问题:

如果使用 GWT Designer 遇到 NoSuchMethodError 或 NoClassDefFoundError 我该怎么办?

https://developers.google.com/web-toolkit/tools/gwtdesigner/faq#NoSuchMethodError

我已经尝试过不同的虚拟机,1.8、1.6;

GWT Designer 仍然有效吗?设计 UI 是更好的选择吗?如何纠正这个错误并使GWT Designer正常工作?

最佳答案

GWT Designer 未维护。它不适用于 GWT 2.6.0 或 2.7,并且可能不适用于较新的版本。虽然它确实适用于 2.6.1,但我不建议使用最新版本以外的任何其他版本,特别是“经典”DevMode 也已被弃用:2.7 是 SuperDevMode 真正可用的第一个版本,并且它将继续在未来的版本中进行改进。

关于java - GWT 设计器不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29464633/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com