You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Макаров Роман <ro...@kupivip.ru> on 2014/09/05 14:56:12 UTC

Dynamic component usage example

Can someone please provide an example of using Dynamic component?

The framework is really complicated and there is lack of documentation.

I have tested the component without success. The code below giving me unrendered output.

I very appreciate your help.


/ Roman M /


public class TrackerDynamic extends Tracker {


    @Property
    private DynamicTemplate dynamicTemplate;

    public String getTestString() {
        return "uuuuuuuu";
    }

    @Override
    void beginRender() {
        super.beginRender();
        dynamicTemplate = new DynamicTemplate() {
            @Override
            public RenderCommand createRenderCommand(final DynamicDelegate delegate) {
                return new RenderCommand() {
                    @Override
                    public void render(MarkupWriter writer, RenderQueue queue) {
                        delegate.getComponentResources().storeRenderVariable("testvar", "test VALUE");

                        queue.startComponent(delegate.getComponentResources());

                        writer.write("asd ${testvar} ${getTestString()} <t:textfield t:id=\"asdf\" />");
                        queue.endComponent();
                    }
                };
            }
        };
    }
}

the tml is

<t:Dynamic template="prop:dynamicTemplate"></t:Dynamic>


RE: Dynamic component usage example

Posted by Макаров Роман <ro...@kupivip.ru>.
Ohh, found your comment :)

// if you want this to come from a string you might need to
 // implement a StringResource by extending AbstractResource

Thanks for your help!

-----Original Message-----
From: Макаров Роман [mailto:roman.makarov@kupivip.ru] 
Sent: Friday, September 05, 2014 5:25 PM
To: Tapestry users
Subject: RE: Dynamic component usage example

Thanks a lot!

Now, the problem is that I need to get template from the database, not a file (is not Dynamic component designed especially for that?)

Is the Resource interface can be implemented to represent a file? The openStream() method looks fine, but what about all other methods, which are file-oriented. Also, the to implementations in the framework both represents files..

-----Original Message-----
From: Lance Java [mailto:lance.java@googlemail.com] 
Sent: Friday, September 05, 2014 5:19 PM
To: Tapestry users
Subject: Re: Dynamic component usage example

You'll need to use the DynamicTemplateParser

eg: http://tinyurl.com/kztrege

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org

RE: Dynamic component usage example

Posted by Макаров Роман <ro...@kupivip.ru>.
Thanks a lot!

Now, the problem is that I need to get template from the database, not a file (is not Dynamic component designed especially for that?)

Is the Resource interface can be implemented to represent a file? The openStream() method looks fine, but what about all other methods, which are file-oriented. Also, the to implementations in the framework both represents files..

-----Original Message-----
From: Lance Java [mailto:lance.java@googlemail.com] 
Sent: Friday, September 05, 2014 5:19 PM
To: Tapestry users
Subject: Re: Dynamic component usage example

You'll need to use the DynamicTemplateParser

eg: http://tinyurl.com/kztrege

Re: Dynamic component usage example

Posted by Lance Java <la...@googlemail.com>.
You'll need to use the DynamicTemplateParser

eg: http://tinyurl.com/kztrege