Hi everybody.

I'm trying to edit an entity via a beaneditform which has some other
entities inside. I'll write down a simple case so that it's easy to
understand the issue.

The tml file has the following line:




This object member is an EntityB object:

public class EntityB{
    private String sb;
    public String getSb() {return sb;}
    public void setSb(String sb) {this.sb = sb;}

    private EntityA ea;
    public EntityA getEa() {return ea;}
    public void setEa(EntityA ea) {this.ea = ea;}
}

EntityA is a simple class:

public class EntityA{
    private String s1;
    public String getS1() {return s1;}
    public void setS1(String s1) {this.s1 = s1;}

    private int i1;
    public int getI1() {return i1;}
    public void setI1(int i1) {this.i1 = i1;}
}

Finally, the page class has the following code:

        @Property
        private EntityB member;

        @Inject
        private BeanModelSource beanModelSource;
        @Inject
        private ComponentResources resources;

        public BeanModel getModel(){
                BeanModel result = 
beanModelSource.createEditModel(EntityB.class,
resources.getMessages());
                result.add("string1",new EntityBPropertyConduit1());
                return result;
                
        }


And the EntityBPropertyConduit1 class is as follows:

public class EntityBPropertyConduit1 implements PropertyConduit {

        @Override
        public Object get(Object instance) {
                EntityB myObject = (EntityB) instance;
                if(myObject.getEa()==null){
                        return new String();
                }
                return myObject.getEa().getS1();
        }

        @Override
        public void set(Object instance, Object value) {
                EntityB myObject = (EntityB) instance;
                String myValue = (String) value;
                if(myObject.getEa()==null){
                        myObject.setEa(new EntityA());
                }
                myObject.getEa().setS1(myValue);
        }

        @Override
        public Class getPropertyType() {
                return String.class;
        }

        @Override
        public <T extends Annotation> T getAnnotation(Class<T> arg0) {
                // TODO Auto-generated method stub
                return null;
        }
}


With all of this, I get the error 

The data type for property 'string1' of
project.example.entities.EntityB@21ec03 is null.


What am I missing?. I though once you give the beanmodel the
propertyconduit, it knows how to deal with the property...



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Trouble-related-with-beaneditform-beanmodel-and-propertyconduit-tp5699891.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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

Reply via email to