Add a getEntityB() in your ComponentB subclass and use entityb.property
instead of entitya.property, as ComponentA.entityA has type EntityA, not
EntityB.
On Mon, 28 Feb 2011 14:08:28 -0300, Nourredine Khadri
<nourredine.kha...@atosorigin.com> wrote:
It is to provide GUI extensibility such as extended forms - Here a rough
description :
Entity models :
public class EntityA {
private String foo;
//accessors
...
}
public class EntityB extends EntityA{
private String bla;
//accessors
...
}
ComponentA :
<t:form t:id="myForm">
foo : <input t:type="textfield" t:id="foo" t:value="myEntity.foo"
name="foo"/>
<t:extension-point id="formExtension"/>
//submit button...
...
</t:form>
public class ComponentA.java {
@Persist
private EntityA myEntity;
@OnEvent(EventConstants.PREPARE_FOR_RENDER)
public void init(){
myEntity = new EntityA();
}
@OnEvent(EventConstants.SUCCESS)
public Object success(){
//call manager to persist data
return List.class;
}
//myEntity accessors
...
}
ComponentB :
<t:extend xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
<t:replace id="formExtension">
bla : <input t:type="textfield" t:id="bla"
t:value="myEntity.bla"
name="bla" />
</t:replace>
</t:extend>
public class ComponentB extends ComponentA {
@Persist
@Property //works with tapestry 5.1, not with 5.2
private EntityB myEntity;
@OnEvent(EventConstants.PREPARE_FOR_RENDER)
public void init(){
myEntity = new EntityB();
//Use setter from the superclass
setEntity(myEntity);
}
// override onsuccess event
@OnEvent(EventConstants.SUCCESS)
public Object sucess(){
//call manager to store data
return List.class;
}
...
}
ComponentA is part of a component library that runs as a standalone app
(i
mean it is not a simple base class).
Nourredine.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
Coordenador e professor da Especialização em Engenharia de Software com
Ênfase em Java da Faculdade Pitágoras
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org