So, if DynamicTemplateParser has a cache by Resource, how is it identifying the resource? Or, just how to avoid the problem?
By the way, now my code looks as following, but not sure it changes the cache behavior: public class TrackerDynamic extends Tracker { private DynamicTemplate dynamicTemplate; public DynamicTemplate getDynamicTemplate() { if (dynamicTemplate == null) { dynamicTemplate = dynamicTemplateParser.parseTemplate( new StringResource(getTemplateString())); } return dynamicTemplate; } ... } -----Original Message----- From: Lance Java [mailto:lance.j...@googlemail.com] Sent: Monday, September 15, 2014 4:37 PM To: Tapestry users Subject: Re: other components inside Dynamic component? Not sure how to fix your issue but I spot another issue. DynamicTemplateParser has a cache by Resource. It looks like you add to the cache for every render. It's only a question of time before you hit out of memory errors. On 15 Sep 2014 06:32, "Макаров Роман" <roman.maka...@kupivip.ru> wrote: > Hi all, > > I have a question regarding Dynamic component. I use it for keeping > parts of tml code in the database. It renders insertions used for > functions calling such us ${someFunc('someParam')} , but it does not > render any tapestry tags correctly. It just omits "t" prefix instead > and adds xmlns attribute. For example, the following code > > <t:if test="true">asdf</t:if> > > Rendered to: > > <if test="true" > xmlns="http://tapestry.apache.org/schema/tapestry_5_3.xsd > ">asdf</if> > > What are the suggestions? Are there any good examples of code in the net? > > Here is My code: > > public class TrackerDynamic extends Tracker { > > @Property > private DynamicTemplate dynamicTemplate; > > @InjectService("DynamicTemplateParser") > private DynamicTemplateParser dynamicTemplateParser; > > private String getTemplateString() { > StringBuilder sb = new StringBuilder( > "<div id=\"trackerDynamic\" xmlns:t=\" > http://tapestry.apache.org/schema/tapestry_5_3.xsd\" > xmlns:p=\"tapestry:parameter\">\n"); > sb.append(...//some code for inserting custom data from database > sb.append("</div>"); > return sb.toString(); > } > > @Override > void beginRender() { > try { > dynamicTemplate = dynamicTemplateParser.parseTemplate( > new StringResource(getTemplateString()) > ); > } catch (Exception ex) { > } > } > } > > > TrackerDynamic.tml: > > <t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" > xmlns:p="tapestry:parameter"> > > <t:Dynamic template="prop:dynamicTemplate"></t:Dynamic> > > </t:container> > > > StringResource.java: > > public class StringResource implements Resource { > > private String tml; > > public StringResource(String tml) { > this.tml = tml; > } > > @Override > public boolean exists() { > return false; > } > > @Override > public InputStream openStream() throws IOException { > return new ByteArrayInputStream(tml.getBytes("UTF-8")); > } > > @Override > public URL toURL() { > return null; > } > > @Override > public Resource forLocale(Locale locale) { > return null; > } > > @Override > public Resource forFile(String relativePath) { > return null; > } > > @Override > public Resource withExtension(String extension) { > return null; > } > > @Override > public String getFolder() { > return null; > } > > @Override > public String getFile() { > return null; > } > > @Override > public String getPath() { > return null; > } > } > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org