ここでは、Wicket 押されたリンクにより処理を分ける にリンクを足してみる
こんな画面を作る
<?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"/>
<br/>
<a wicket:id="diaryLink">
<span wicket:id="diaryLinkLabel">Link to Diary Application</span>
</a>
<br/>
</form>
</body>
</html>
package com.snail;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.link.Link;
import java.util.Date;
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") {
private static final long serialVersionUID = 98807310206616234L;
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.");
}
};
private Label diaryLinkLabel = new Label("diaryLinkLabel",
new Date() + "の日記を書く");
private Link diaryLink = new Link("diaryLink") {
@Override
public void onClick() {
System.out.println("Clicked Diary Link.");
setResponsePage(new HomePage(new DiaryVO()));
}
};
public MenuPage(final PageParameters parameters) {
this();
}
public MenuPage() {
add(form);
form.add(diaryButton);
form.add(validationButton);
form.add(diaryLink);
diaryLink.add(diaryLinkLabel);
}
}
[Mon Feb 04 01:03:18 JST 2008の日記を書く] を押すと