2008年10月21日 星期二

Wicket的Include元件

一個網站多少都需要連結到一般靜態的網頁,透過Include元件可以很方便的連結到靜態網頁.
步驟一.建置一個IncludeExamples.html

<html>
<body>
<form wicket:id="form">
<span wicket:id ="include">在這裏放置通用的Html代碼</span>
</form>
</body>
</html>

步驟二.建置IncludeExamples.java

package wicket.examples.html.body.form.include;

import wicket.examples.html.body.base.hello.HelloWicket;
import wicket.markup.html.WebPage;
import wicket.markup.html.form.Form;
import wicket.markup.html.include.Include;

public class IncludeExamples extends WebPage {

public IncludeExamples(){
super();
Form cForm = new Form("form");
cForm.add(new Include("include","index.html"));
this.add(cForm);
}
}

步驟三.建置一靜態網頁index.html

<html>
<body>
<h3>這是一個靜態網頁</h3>
</body>
</html>

步驟四.修改Examples.html & Examples.java

...
<tr>
<td><a wicket:id="Examples9">show IncludeExamplesPage</a></td>
</tr>
...


...
add(new PageLink("Examples9",IncludeExamples.class));
...

沒有留言: