You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Otho <ta...@googlemail.com> on 2008/01/06 16:48:50 UTC

T5 Grid How to show embedded property-values?

Hi all,

How is it possible to show properties of embedded objects in a grid?

Example:

class Master
{
  String name;
  Slave slave;
}


class Slave
{
  String name;
  Date enslaved;
}


The grid should show:

Name (master) - Name (slave) - Date enslaved


When I constuct a BeanModel for this with fieldnames like String[] {"name",
"slave.name", "slave.enslaved"} ist doesn't work and I could not find an
easy way to combine BeanModels for Master and Slave.
 Is there any possibility not using Transfer-Objects?

Regards,
Otho

Does tapestry provide UI composition/layout solution?

Posted by "Zheng, Xiahong" <Xi...@FMR.COM>.
Hi,

Can somebody direct me to the relevant doc or examples that demonstrate
the UI composition (similar to tiles or facelets) capability for both
Tapestry 4 and 5. I am about to convert an existing tiles based
application as part of the WEB MVC framework evaluation process and this
is the first thing that got me stumbled.

Thanks,
Xiaohong

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


Re: T5 Grid How to show embedded property-values?

Posted by Otho <ta...@googlemail.com>.
I created a service to create beanmodels like this:

public class BeanModelHelperImpl implements BeanModelHelper
{
/**
     * Create a BeanModel for a class from an ordered array of
     * Strings for the fieldnames.
     *
     * @param clazz  the class for which the model is to be built
     * @param fields the Fieldnames
     * @return the created BeanModel
     */
public BeanModel createBeanModel(Class clazz, String[] fields,
                                     BeanModelSource beanModelSource,
                                     ComponentResources componentResources)
    {
        HashSet<String> fieldNames = new HashSet<String>();

        for (String s : fields)
        {
            fieldNames.add(s.toLowerCase());
        }

        BeanModel beanModel = beanModelSource.create(clazz, false,
componentResources);

        List<String> actualProperties = beanModel.getPropertyNames();
        for (String s : actualProperties)
        {
            if (!fieldNames.contains(s.toLowerCase()))
                beanModel.remove(s);
        }
        beanModel.reorder(fields);
        return beanModel;
    }
}

If I call this with a line like

Beanmodel model = beanModelHelper.createBeanModel(Master.class, new
String[]{"name","slave.name","slave.enslaved", source, resources);

an exception is thrown:

Bean editor model for entities.Master does not contain a property named
'slave'. Available properties: name.

This is to be expected since the beanModel created by the beanModelSource
contains only the primitive (and Date) properties of any given class it
seems, so when I have a property which itself is a class with primitive
properties as in the example there seems to be no easy way get these into a
BeanModel save by creating a new class with the needed properties as a kind
of transferobject.

Re: T5 Grid How to show embedded property-values?

Posted by Howard Lewis Ship <hl...@gmail.com>.
That's supposed to work.  Please show more of your code.

On Jan 6, 2008 7:48 AM, Otho <ta...@googlemail.com> wrote:
> Hi all,
>
> How is it possible to show properties of embedded objects in a grid?
>
> Example:
>
> class Master
> {
>   String name;
>   Slave slave;
> }
>
>
> class Slave
> {
>   String name;
>   Date enslaved;
> }
>
>
> The grid should show:
>
> Name (master) - Name (slave) - Date enslaved
>
>
> When I constuct a BeanModel for this with fieldnames like String[] {"name",
> "slave.name", "slave.enslaved"} ist doesn't work and I could not find an
> easy way to combine BeanModels for Master and Slave.
>  Is there any possibility not using Transfer-Objects?
>
> Regards,
> Otho
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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