Wicket - 获取标记元素的主体
假设我有如下所示的标记:
<span wicket:id="text">Some text that I'd like to read</span>
是否可以在某处获取标签正文的内容,或者它是否被检票口不可挽回地剥离?
编辑: 我的目的是实现某种简单的 CMS。用户需要能够以 tex>a^2
的形式输入 LaTeX 公式,然后我将使用 RenderedDynamicImageResource 进行渲染。其他标签需要以类似的方式解释。我设想用这样的 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
...
}
}
我已经在这个问题上苦苦挣扎了一段时间,所以也许我正在寻找错误的方向。
Assuming I have markup that looks like this :
<span wicket:id="text">Some text that I'd like to read</span>
Is it possible to get the content of the body of the tag somewhere, or is it irremediably stripped by wicket?
Edit :
My intent is to implement some kind of simple CMS. Users need to be able to enter LaTeX formulas, in the form of tex>a^2</tex>
that I would then render with a RenderedDynamicImageResource. Other tags need to be interpreted in a similar way. I envisioned to do it in two steps with a Panel
like this :
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
...
}
}
I've been struggling with this problem for a while, so maybe I'm searching in the wrong direction.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
组件的
MarkupStream
对象包含原始 HTML 主体。您可以使用 markupStream.get().toString() 方法检索它,如下所示:
The
MarkupStream
object of the Component contains the raw HTML body.You can retrieve it using the markupStream.get().toString() method like this: