T5 Grid How to show embedded property-values?

2008-01-06 Thread Otho
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


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

2008-01-06 Thread Howard Lewis Ship
That's supposed to work.  Please show more of your code.

On Jan 6, 2008 7:48 AM, Otho [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



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

2008-01-06 Thread Otho
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)
{
HashSetString fieldNames = new HashSetString();

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

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

ListString 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.