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;
>     }
> }
>
>

Reply via email to