-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I have
<html id="html" />
I am generating a content as a string in my application.
StringBuilder sb = new StringBuilder(); sb.append(<ul><li>).append... html.setContent(sb.toString());
Is there any way, how to use DSP or JSP as templates to build a content of html tag, so as EL expressions may be used? I mean a template l like
<li>${arg.name} has ${arg.count} items</li>
for (...) { sb.append(load("template.jsp, arg)); }
I know I can use some templates, like FreeMaker with ZK. But I need this just for one page so I do not want to employ a special technology for that.
Thanks
Andy
If you set variable names in doBeforeCompose(...) you can use those in EL.
Cary: I would like to use some simple HTML template, without any ZK controller. I.e. I have to make a list
<ul> <li>...<li> <li>...<li> </ul>
I would like to have some template for the <li>....</li>, which would resolve EL variables. I would like to reuse this template with different values. I do not want to use EL "forEach", since I would like to plug the templates together sometimes.
This problem is not a much ZK related. I just the whole app written in ZK, so I would be happy, if I could use ZK for this problem, too.
Got it:
ExpressionEvaluatorImpl evaluator = new ExpressionEvaluatorImpl(true); Map map = new HashMap(); map.put("cosi", 2); map.put("cosi2", 4); SimpleResolver sr = new SimpleResolver(map); Object value = evaluator.evaluate("Hello ${cosi} and maybe ${cosi2}.", String.class, sr, null);
Asked: 2010-11-12 10:19:04 +0800
Seen: 280 times
Last updated: Nov 15 '10