Dynamic markup in Wicket

僤鯓⒐⒋嵵緔 提交于 2019-12-12 08:21:23

问题


Is it possible to generate the markup for a MarkupContainer dynamically, i.e. without storing an HTML file for it?

I thought about reading the markup as a plain string from the database to offer CMS-like functionality.


回答1:


Interesting question and I'm not sure if it is possible, but my guess would be to start off looking at the IMarkupLoader and IMarkupResourceStreamProvider interfaces and implementing classes and see how far you get from there.
I'd be interested in anything you find / implement that actually gets this done!




回答2:


Another (simpler) way to do it would be to use a label with disabled markup escaping :

Label<String> label = new Label<String>("id", "<a href='....'><span>foo<em>bar</em></span></a>");
label.setEscapeModelStrings(false);
add(label);

Be careful though, as this might lead to security breaches (HTML/JS injection).



来源:https://stackoverflow.com/questions/2086732/dynamic-markup-in-wicket

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!