e.g.
public class Network {
private Network parent;
private Set<Network> children;
}
Again there is only an opportunity to define the bean's display
context once which I suppose becomes applicable to all instances on
the page... This will created an infinite recurrence of parent
instances unless you exclude the property entirely.
I really couldn't get my head around how the metadata is structured
and used but I had a crack at adding a context annotation... and to
hook it in the only way I could find was to modify
ElementMetaData.createBeanMetaData() to:
public BeanMetaData createBeanMetaData(Class beanType, boolean
viewOnly)
{
// Compose a keyPrefix from the original bean meta data, the
base bean class name, and this property name.
BeanMetaData parentMetaData = getBeanMetaData();
// return new BeanMetaData(beanType,
parentMetaData.getContext(), parentMetaData.getBeansMetaData(),
parentMetaData.getMetaDataClass(), parentMetaData.getComponent(),
// parentMetaData.getComponentRegistry(), viewOnly,
true);
return new BeanMetaData(beanType,
getBestContext(parentMetaData), parentMetaData.getBeansMetaData(),
parentMetaData.getMetaDataClass(), parentMetaData.getComponent(),
parentMetaData.getComponentRegistry(), viewOnly,
true);
}
also added:
public String getBestContext(BeanMetaData parentMetaData) {
String context = getParameter(PARAM_CONTEXT);
if (context != null && !context.isEmpty())
return context;
return parentMetaData.getContext();
}
This works sometimes... Sometimes I get an error during instantiation
of the BeanMetaData because it fails to find the context which I
suspect is because it's looking at the wrong bean. This always
happens if I add the context annotation to a child field of type
Network (where the main display bean is Network)....
Can one of the developers give me any hints how I could do this
properly? Happy to submit the modified code for approval/inclusion if
I can get it working neatly. I really think think this would add a
huge amount of flexibility to this project if were possible.
Completely unrelated but one other feature that would be great is an
option to default to display only properties that are specified rather
than all. I have many beans with loooooong lists of properties and
quite often will only want to display a small subset.