2011-01-05 10 views
1

のボディを取得:ウィケット - 私はこのようになり、そのマークアップを持っていると仮定すると、マークアップ要素

<span wicket:id="text">Some text that I'd like to read</span> 

それはどこかに、タグのボディのコンテンツを取得するために、またはそれがirremediably改札によって取り除かれることは可能ですか?

編集: 私の意図は、単純なCMSのいくつかの種類を実装することです。ユーザーは、tex>a^2</tex>という形で、RenderedDynamicImageResourceでレンダリングするLaTeX式を入力する必要があります。他のタグも同様の方法で解釈する必要があります。私はこのようなPanelと二段階でそれを行うことを想定:

public class LightweightMarkupPanel extends Panel implements IComponentResolver { 
    public LightweightMarkupPanel (String id) { 
     super(id); 
    } 

    @Override 
    public MarkupStream getAssociatedMarkupStream(boolean throwException) { 
     // Get the lightweight markup and convert it to wicket markup 
     ... 
    } 

    @Override 
    public boolean resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) { 
     // AutoAdd components as needed 
     ... 
    } 
} 

私はしばらくの間、この問題で苦労してきたので、多分私は間違った方向に検索しています。

+0

ここでコンテンツを取得しますか? 「読んでみたいテキスト」を残しておきたいですか? – jzd

答えて

4

コンポーネントのMarkupStreamオブジェクトには、生のHTML本文が含まれています。 次のようにmarkupStream.get()。toString()メソッドを使用して取得できます。

// <span wicket:id="message">message will be here</span> 
add(new Label("message", "If you see this message ..."){ 
    @Override 
    protected void onComponentTagBody(
     MarkupStream markupStream, ComponentTag openTag) { 
     markupStream.get(); // "message will be here" 
     super.onComponentTagBody(markupStream, openTag); 
    } 
}); 
関連する問題