ここでは、簡単なメニュー画面を作って、ボタンによって処理を分けることを試してみる
こんな画面を作る
<?xml version="1.0" encoding="UTF-8"?>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org/">
<head>
<title>Wicket Examination Menu Page</title>
</head>
<body>
<strong>Wicket Examination Menu Page</strong>
<br/><br/>
<form wicket:id="f">
<input type="submit" wicket:id="diary" value="Diary"/>
<input type="submit" wicket:id="validation" value="Validation"/>
</form>
</body>
</html>
package com.snail;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
public class MenuPage extends WebPage {
private Button diaryButton = new Button("diary") {
@Override
public void onSubmit() {
System.out.println("Pushed Diary Button.");
setResponsePage(new HomePage(new DiaryVO()));
}
};
private Button validationButton = new Button("validation") {
@Override
public void onSubmit() {
System.out.println("Pushed Validation Button.");
setResponsePage(new ValidationExamPage());
}
};
private Form form = new Form("f") {
@Override
public void onSubmit() {
System.out.println("Form Submitted.");
}
};
public MenuPage(final PageParameters parameters) {
this();
}
public MenuPage() {
add(form);
form.add(diaryButton);
form.add(validationButton);
}
}
[Diary] ボタンを押したときのログ。