我正在写 History.newItem("step2") 但即使在执行此指令之后,它应该调用的方法也是 public void onValueChange(ValueChangeEvent event) { //code }
但是当我这样做时,没有调用该方法,我不明白为什么它没有调用该方法。
下面是整个代码。
{
package org.adrianwalker.gwt.uploadprogress.client;
import com.google.gwt.user.client.History;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
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 org.adrianwalker.gwt.uploadprogress.client.view.UploadProgressView;
public final class UploadProgress implements EntryPoint, ValueChangeHandler {
private static final UploadProgressView UPLOAD_PROGRESS_VIEW = new UploadProgressView();
Label step_co=new Label("Step1");
@Override
public void onModuleLoad() {
Button next1=new Button("Next");
AbsolutePanel master_panel=new AbsolutePanel();
//RootPanel rootPanel = RootPanel.get("content");
master_panel.setStyleName("master_panel");
master_panel.setHeight("100px");
master_panel.setWidth("300px");
master_panel.add(step_co,100,25);
RootPanel.get("master").add(master_panel,100,25);
RootPanel.get("content").add(UPLOAD_PROGRESS_VIEW,100,150);
RootPanel.get("content").add(next1);
next1.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
History.newItem("step2",true);
RootPanel.get().add(new Label(History.getToken()));
// changeStep("token");
}});
RootPanel.get("content").add(next1,150,550);
}
public void onValueChange(ValueChangeEvent event)
{
RootPanel.get().add(new Label("In value change"));
String token=History.getToken();
changeStep(token);
}
public void changeStep(String token)
{
if(token.equals("step2"))
{
step_co.setText("Step2");
RootPanel.get("content").clear();
}
}
}
}
请告诉我如何在 History.newItem(("step2") 指令中调用 public void onValueChange(ValueChangeEvent event) 方法。