API リファレンス
ダウンロード
- RSSの取り出しに失敗しました:http://sourceforge.jp/projects/paraselene/releases/rss
例として、テキストボックスが選ばれたら記入済み文字列が全選択されるクラスを作成します。
実際には、以下のような HTML で実現可能です(Google Chrome では、クリックすると選択解除されてしまいますが…)。
1:
<input type="text" onfocus="this.select()">
このため、わざわざ派生クラスを作成するまでもない処理ですが、サンプルを簡単にするため、このような例で作成します。
カスタマイズする対象は、次の3つとします。
| No | 部品 | Paraseleneでのクラス | |
|---|---|---|---|
| 1 | 複数行テキストボックス | <textarea></textarea> | paraselene.tag.form.MultiTextBox |
| 2 | 1行テキストボックス | <input type="text"> | paraselene.tag.form.SingleTextBox |
| 3 | パスワード用テキストボックス | <input type="password"> | |
パッケージ名は lib とします。まず、MultiTextBox の派生クラスを作成します。
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
package lib; import paraselene.tag.*; import paraselene.tag.attr.*; import paraselene.tag.form.*; public class CustomMultiTextBox extends MultiTextBox { public CustomMultiTextBox() { super(); setAttribute( new Attribute( "onfocus", "this.select()" ) ); } protected Tag newReplica() { return new CustomMultiTextBox(); } }
タグの派生クラスを作成する場合、以下の事を必ず行って下さい。
続いて、SingleTextBox の派生クラスを作成します。
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
package lib; import paraselene.tag.*; import paraselene.tag.attr.*; import paraselene.tag.form.*; public class CustomSingleTextBox extends SingleTextBox { public CustomSingleTextBox( boolean pw_f ) { super( pw_f ); setAttribute( new Attribute( "onfocus", "this.select()" ) ); } protected Tag newReplica() { return new CustomSingleTextBox( isPassword() ); } }
SingleTextBox はコンストラクタの引数で、パスワード入力か否かを指定する仕様になっています。
このため、派生クラスのコンストラクタも引数を受け付けるようにし、newReplica でも引数を渡します。