You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Anton Mezerny <an...@gmail.com> on 2010/09/28 22:30:33 UTC

Strange beaneditor behaviour

Hi!

I have 2 classes:
public static class Parent{
        private String name;
        private String description;
        private Child child;

        //getters and setters
    }

   public static class Child{
        private String childName;
        private String childDescr;
        //getters and setters
    }

Everything renders fine, when I have the Parent object with the Child object
nested in it, and I try to render this combination like here:
<t:form>
<t:beaneditor object="parent" add="child">
    <t:parameter name="child">

        <t:beaneditor object="parent.child"/>

    </t:parameter>
</t:beaneditor>
</t:form>

But if I change Parent class to:

 public static class Parent{
        private String name;
        private String description;
        private Object child; //changed to Object instead of Child
//getters and setters
}

my nested child object doesn't renders on the page. There is no any
exception - just child's fields disappear.

Is it normal behaviour, or a bug? And if normal, why can't beaneditor
resolve class type and render child object like in first example above?

Re: Strange beaneditor behaviour

Posted by Anton Mezerny <an...@gmail.com>.
Thank you, Howard, now it's clear.
But I have one more question - instead beaneditor, I tried to nest
beandisplay component into the parent beaneditor and despite all it works
fine even if it gets Object, not Child. Why in this case it works in a
different way?


2010/9/28 Howard Lewis Ship <hl...@gmail.com>

> Normal behavior.  Tapestry builds a model (the BeanModel) to identify
> the properties to edit. It does this based on the type of the
> property, which is statically determined.  The original type of the
> parent.child expression was Child.  When you changed the child
> property to be type Object, Tapestry built a model for Object, which
> as no properties.
>
> You can, alternatively, use the BeanModelSource to build a model
> object from Child.class, and pass that directly to the BeanEditor via
> its model parameter.
>
>
> On Tue, Sep 28, 2010 at 1:30 PM, Anton Mezerny <an...@gmail.com>
> wrote:
> > Hi!
> >
> > I have 2 classes:
> > public static class Parent{
> >        private String name;
> >        private String description;
> >        private Child child;
> >
> >        //getters and setters
> >    }
> >
> >   public static class Child{
> >        private String childName;
> >        private String childDescr;
> >        //getters and setters
> >    }
> >
> > Everything renders fine, when I have the Parent object with the Child
> object
> > nested in it, and I try to render this combination like here:
> > <t:form>
> > <t:beaneditor object="parent" add="child">
> >    <t:parameter name="child">
> >
> >        <t:beaneditor object="parent.child"/>
> >
> >    </t:parameter>
> > </t:beaneditor>
> > </t:form>
> >
> > But if I change Parent class to:
> >
> >  public static class Parent{
> >        private String name;
> >        private String description;
> >        private Object child; //changed to Object instead of Child
> > //getters and setters
> > }
> >
> > my nested child object doesn't renders on the page. There is no any
> > exception - just child's fields disappear.
> >
> > Is it normal behaviour, or a bug? And if normal, why can't beaneditor
> > resolve class type and render child object like in first example above?
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Strange beaneditor behaviour

Posted by Howard Lewis Ship <hl...@gmail.com>.
Normal behavior.  Tapestry builds a model (the BeanModel) to identify
the properties to edit. It does this based on the type of the
property, which is statically determined.  The original type of the
parent.child expression was Child.  When you changed the child
property to be type Object, Tapestry built a model for Object, which
as no properties.

You can, alternatively, use the BeanModelSource to build a model
object from Child.class, and pass that directly to the BeanEditor via
its model parameter.


On Tue, Sep 28, 2010 at 1:30 PM, Anton Mezerny <an...@gmail.com> wrote:
> Hi!
>
> I have 2 classes:
> public static class Parent{
>        private String name;
>        private String description;
>        private Child child;
>
>        //getters and setters
>    }
>
>   public static class Child{
>        private String childName;
>        private String childDescr;
>        //getters and setters
>    }
>
> Everything renders fine, when I have the Parent object with the Child object
> nested in it, and I try to render this combination like here:
> <t:form>
> <t:beaneditor object="parent" add="child">
>    <t:parameter name="child">
>
>        <t:beaneditor object="parent.child"/>
>
>    </t:parameter>
> </t:beaneditor>
> </t:form>
>
> But if I change Parent class to:
>
>  public static class Parent{
>        private String name;
>        private String description;
>        private Object child; //changed to Object instead of Child
> //getters and setters
> }
>
> my nested child object doesn't renders on the page. There is no any
> exception - just child's fields disappear.
>
> Is it normal behaviour, or a bug? And if normal, why can't beaneditor
> resolve class type and render child object like in first example above?
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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