かなりよくある質問
以下、http://wiki.apache.org/jakarta-tapestry/MoreFrequentlyAskedQuestions の抜粋andOr要約andOr追記
ページからページに情報を渡すには?
以下のようにします。
呼び元
public void submitAction(IRequestCycle cycle) { // The next page we want to go to is the Result page AppointmentPage next_page = (AppointmentPage)cycle.getPage("Appointment"); next_page.setDate(new Date()); next_page.setEvent(“Birthday Party”); cycle.activate(next_page); }
Appointment ページ仕様
<property-specification name="date" type="java.lang.Date" persistent="yes"/> <property-specification name="event" type="java.lang.String" persistent="yes"/>
Appointment ページクラス:
/* ** Generated derived class implements these routines and connects them to the properties. ** You only need to create these abstract routines if you are referencing them within the ** abstract class. */ public abstract void setDate(Date date); public abstract void setEvent(String event); public abstract Date getDate(); public abstract String getEvent();
新しくページを作成したけど、'class instantiation problem'と言われてインスタンスに出来ないのですが
作ったページクラスがabstractなのが原因です。abstractなプロパティがある場合、必ず<property-specification>でページ仕様に記述していないとそのクラスのインスタンス生成に失敗します。
でも、3.0.1からは大丈夫になりました。
jwcid=$content$タグは何ですか?また、jwcid=$remove$タグは何ですか?
Tapestryは、HTML内に
<span jwcid=”$content$”></span>
があると、そのタグに囲まれていない部分は処理しません。
$remove$は、上記$content$と逆で、
<span jwcid=”$remove$”></span>
がHTMLに記述されていると、Tapestryはそのタグ内に書かれている内容を無視します。$remove$と$content$をうまく使うことで、Tapestryを介さずにHTMLの静的な状態(紙芝居)のレイアウトの確認が出来るようになります。
なぜかVisitがいつもnullだったり、NoClassDefFoundErrorが投げられたりします
アプリケーション仕様にVisitの定義を書いていないからじゃないですかね?
MyApp.application
<property name="org.apache.tapestry.visit-class" value="some.example.Visit" />
AppointmentPage.java
Public void submit() { // getVisit() will need to be casted to the defined Visit class some.example.Visit visit = (some.example.Visit)getPage().getVisit(); }