Fight the Future

Java言語とJVM、そしてJavaエコシステム全般にまつわること

Introducing Apache Wicketの超意訳(2)

http://www.theserverside.com/tt/articles/article.tss?l=IntroducingApacheWicket

All Wicket components are designed to be extended.
Extension can be simple: an anonymous class to link to another page, for instance.
If you have the same component component on several pages, like a search form,
you can encapsulate it into an easily reusable component.

Wicketコンポーネントはすべて拡張できるように設計されています。
拡張は簡単です。例えば他のページにリンクする無名クラスのようなものです。
もしいくつかのページに検索フォームのような同じコンポーネントがあるなら、
簡単に再利用できるコンポーネントカプセル化できます。

Components are added to other components, including a special type of component called a MarkupContainer.
MarkupContainers are special because, in addition to Java code,
they have an associated markup file, like HTML.
Pages and Panels are the two most common types of MarkupContainers you'll encounter.
We'll look at both later in the example application.

コンポーネントは、MarkupContainerと呼ぶ特別なタイプのコンポーネントを含む他のコンポーネントに追加できます。
MarkupContainerは特別です。なぜならJavaコードに加えてHTMLのような関連のあるマークアップファイルを保持しているからです。
よく出くわすMarkupContainerを2つ挙げると、PageとPanelでしょう。
後述するサンプルアプリケーションのところでPageとPanelを解説します。

Let's look at a simple wireframe of a hypothetical page with components:

コンポーネントを使った仮想ページの単純なワイヤーフレームを見てみましょう。

In the above illustration, our Page object has multiple components,
including two Panels, a Form with multiple FormComponents (drop down, text field, radio buttons, etc.) and a Link.
Child components are added to a single parent component, essentially creating an inverted tree:

上の図では、ページは複数のコンポーネントを持っています。
そこには2つのパネルと複数のFormComponent(ドロップダウン、テキストフィールド、ラジオボタンなど)、リンクがあります。
コンポーネントは単一の親コンポーネントに追加します。本質的には反転したツリーを作成します。

Component references must appear in the markup in the same structure as the code.
For example, an exception is thrown if you add one of the Buttons outside the

element block.
(These kinds of exceptions can be difficult to track down, so Wicket provides helpful error pages when running in development mode.)

コンポーネントの参照はコードとして同じ構造にあるマークアップに表れます。
たとえば、<form>要素のブロックの外にButtonの1つを追加した場合に例外をスローします。
(この種の例外は見つけ出すのが難しいです。そのためWicketは開発モードで動作させているときには役に立つエラーページを提供しています。)


To summarize, Wicket components are Java classes with supporting HTML markup.
Most Wicket components are designed to be customized for your specific needs.
Components may be customized by creating anonymous classes or concrete subclasses.
Components work with Models, which are the subject of the next section.

まとめると、WicketコンポーネントはHTMLのマークアップをサポートしたJavaのクラスです。
Wicketコンポーネントはほとんど特定の要求に対してカスタマイズできるように設計されています。
コンポーネントは無名クラスまたは具象サブクラスを作成してカスタマイズします。
コンポーネントはモデルと連携して動作します、次の節ではモデルを主題にします。