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

ParentComponent.tml:
<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/>

    <extension-point id="body_child"/>
</container>


ParentComponent.java:
public abstract class ParentComponent {

    @Property
    @Parameter(required=true)
    private String param1;
    @Property
    @Parameter(required=true)
    private String param2;
    @Property
    @Parameter(required=true)
    private String param3;

}

C1.tml
<t:extend xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";
xmlns:p="tapestry:parameter" t:content="text/html; charset=utf-8">
    <t:replace id="body_child">
        body of c1 ${param1}, ${param2}, ${param3}
    </t:replace>
</t:extend>

C1.java
public class C1 extends ParentComponent {
}

test.tml:
...
<t:c1 param1="1" param2="2" param3="3"/>
...

Thanks in advance.

Reply via email to