「【Wicket】リンクの作り方」の編集履歴(バックアップ)一覧に戻る

【Wicket】リンクの作り方 - (2007/10/04 (木) 17:01:21) のソース

*リンクの作り方
このページでは、[[Wicket-Examples>http://wicketstuff.org/wicket13/compref/]]のサンプルソースに書いてある内容を解読してみますっ

*▼wicket.markup.html.link.Link
[[このページ>http://wicketstuff.org/wicket13/compref/?wicket:bookmarkablePage=%3Aorg.apache.wicket.examples.compref.LinkPage]]では、普通(?)のリンクの使い方を説明してるっぽいです。

**基本的な使い方
以下のような普通のAタグを作る場合。
><a href="#" wicket:id="link1">this link is clicked <span wicket:id="label1">n</span> times</a>

Pageクラスでは、こんな感じで書きます。

> Link link1 = new Link("link1")
> {
>    public void onClick()
>    {
>        count1.clicks++;
>    }
> };
> add(link1);
> 
> // add a counter label to the link so that we can display it in the body
> // of the link
> link1.add(new Label("label1", new Model()
> {
>    public Object getObject()
>    {
>        return Integer.toString(count1.clicks);
>    }
> }));

ポイントは以下です。
-Linkクラスが、リンクを処理する基本クラス。
-クリック時の処理は、onClick() メソッドをオーバーライド
-表示文字を可変にする場合は、Labelをネストさせる。










-ボタンタグの場合( <a href="..." >xxx</a> )
-inputタグの場合( <input type="button" value="xxx" /> )


*アンカータグの場合( <a href="..." >xxx</a> )


*ボタンタグの場合( <a href="..." >xxx</a> )



*inputタグの場合( <input type="button" value="xxx" /> )