On Thu, 06 Feb 2014 16:05:04 -0200, iberck <ibe...@gmail.com> wrote:

hi all,

Hi!

how can I transform the next example from inheritance design to
composition design ?

You don't even need to have two different components to have a component which can have a part of its template replaced:

ParentComponent.tml:
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";
 xmlns:p="tapestry:parameter" t:content="text/html; charset=utf-8">
        this is parent component<br/>
        <t:delegate to="prop:blockToRender"/>
        <t:block id="defaultBlock">default stuff.</t:block>
</t:container>

ParentComponent.java:
@SupportsInformalParameters
public class ParentComponent {

     @Parameter(required=true)
     private String param1;

     @Parameter(required=true)
     private String param2;

     @Parameter(required=true)
     private String param3;

     @Parameter(required=true, value="block:defaultBlock")
     private Block blockToRender;

     @Inject
     @Property
     private Block defaultBlock;

     // getters for parameters

 }

When using the component above:

<t:block id="myBlock">
<t:ParentComponent blockToRender="block:myBlock"/>

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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

Reply via email to