开发者

Load a new page after submitting a form in Java

开发者 https://www.devze.com 2023-03-19 15:40 出处:网络
I am doing my first Java website, where a form in the war/MyWeb.html is managed from MyWeb.java. What I want is that, after submitting the form, a new webpage MyWeb2.html is loaded. How can I do that?

I am doing my first Java website, where a form in the war/MyWeb.html is managed from MyWeb.java. What I want is that, after submitting the form, a new webpage MyWeb2.html is loaded. How can I do that? I have a comment where I think this code should go... THANKS

PIECE OF MyWeb.html

<table align="center">
<tr>
  <td id="fileChooserContainer" align="left"></td>
</tr>
<tr>
  <td id="submitButtonContainer" align="right">&l开发者_运维技巧t;/td>
</tr>
</table>

PIECE OF MyWeb.java

public void onModuleLoad() {
  final Button submitButton = new Button("Submit");
  final FileUpload chooser = new FileUpload();
  RootPanel.get("submitButtonContainer").add(compressButton);
  RootPanel.get("fileChooserContainer").add(chooser);

  class EncoderHandler implements ClickHandler, KeyUpHandler {
    public void onClick(ClickEvent event) {
        loadNewPage();
    }

    private void loadNewPage() {
    // What do I have to code here to open a MyWeb2.html???
    }
  }

  EncoderHandler handler = new EncoderHandler();
  submitButton.addClickHandler(handler);
}       


You can use

Window.Location.assign(url);

for this purpose.

0

精彩评论

暂无评论...
验证码 换一张
取 消