組み込みカスタムタグの動的コンテンツ(子タグ)なレンダリング
-
09-06-2019 - |
質問
組み込みカスタムタグの動的コンテンツ(子タグ)はrendering.
私のページを牽引する動的コンテンツからjavabeanスのリストオブジェクトのカスタムタグを処理ます。各オブジェクトチに出力されるhtmlのを含む第二のカスタムタグを作成することも描画されます。このタグを呼び出しはされます。
たとえばれています。
1プル情報データベースからのページを介してjavabean.この情報をカスタムタグを出力す.
<jsp:useBean id="ImportantNoticeBean" scope="page" class="com.mysite.beans.ImportantNoticeProcessBean"/> <%-- Declare the bean --%>
<c:forEach var="noticeBean" items="${ImportantNoticeBean.importantNotices}"> <%-- Get the info --%>
<mysite:notice importantNotice="${noticeBean}"/> <%-- give it to the tag for processing --%>
</c:forEach>
このタグに出力ボックス事業部はこのように
*SNIP* class for custom tag def and method setup etc
out.println("<div class=\"importantNotice\">");
out.println(" " + importantNotice.getMessage());
out.println(" <div class=\"importantnoticedates\">Posted: " + importantNotice.getDateFrom() + " End: " + importantNotice.getDateTo()</div>");
out.println(" <div class=\"noticeAuthor\">- " + importantNotice.getAuthor() + "</div>");
out.println("</div>");
*SNIP*
この微細描画し、期待どおりに
<div class="importantNotice">
<p>This is a very important message. Everyone should pay attenton to it.</p>
<div class="importantnoticedates">Posted: 2008-09-08 End: 2008-09-08</div>
<div class="noticeAuthor">- The author</div>
</div>
2の場合、上記の例では、例えば、私たカスタムタグのimportantNotice.getMessage()文字列:
*SNIP* "This is a very important message. Everyone should pay attenton to it. <mysite:quote author="Some Guy">Quote this</mysite:quote>" *SNIP*
の重要なお知らせする微細な引用のタグを処理できませんで挿入する文字列を入れてtext/htmlタグです。
<div class="importantNotice">
<p>This is a very important message. Everyone should pay attenton to it. <mysite:quote author="Some Guy">Quote this</mysite:quote></p>
<div class="importantnoticedates">Posted: 2008-09-08 End: 2008-09-08</div>
<div class="noticeAuthor">- The author</div>
</div>
よ
<div class="importantNotice">
<p>This is a very important message. Everyone should pay attenton to it. <div class="quote">Quote this <span class="authorofquote">Some Guy</span></div></p> // or wahtever I choose as the output
<div class="importantnoticedates">Posted: 2008-09-08 End: 2008-09-08</div>
<div class="noticeAuthor">- The author</div>
</div>
いいプロセッサーおよびプレ-プロセッサーがいないということです。
解決
だけを使用
<bodycontent>JSP</bodycontent>
いのではない。を行うと良いでしょうsoimethingのように
JspFragment body = getJspBody();
StringWriter stringWriter = new StringWriter();
StringBuffer buff = stringWriter.getBuffer();
buff.append("<h1>");
body.invoke(stringWriter);
buff.append("</h1>");
out.println(stringWriter);
車内のタグが描画される(例としては、SimpleTag doTag法です。
しかし、問題のコードいたように、これまでとは違った内部タグが再開から文字列ではないと判の一部としてJSP、一部のランダムな文字列になります。とは思えないとして用いられるJSP translatorを構文解析します。
利用できる正規表現には、ごみの再設計コードについてjspのようになります:
<jsp:useBean id="ImportantNoticeBean" scope="page class="com.mysite.beans.ImportantNoticeProcessBean"/>
<c:forEach var="noticeBean" items="${ImportantNoticeBean.importantNotices}">
<mysite:notice importantNotice="${noticeBean}">
<mysite:quote author="Some Guy">Quote this</mysite:quote>
<mysite:messagebody author="Some Guy" />
</mysite:notice>
</c:forEach>
I履行regexp.
他のヒント
私は傾斜を変える"建築のタグ付け"のデータをご希望の達成に必要ないことによりタグの内部クラスはそのまま"のマークアップ"デザインされたページ(が掛 を取得できることが、メラノーマ診断支援システムスレッドJSPのサーブレットエンジン
何だろにより、内標準的手続きを"協力しタグ"を BodyTagSupport
クラスは拡張子を返し EVAL_BODY_BUFFERED
にdoStartTag()メソッドを繰り返す工程を体 および/または オブジェクトの共有などの保管retrivedデータの階層のセッションのセッションに作業を行うことができます。
見 oracle j2eeカスタムタグチュートリアル ます。