Default context inside table

0 views
Skip to first unread message

shadders

unread,
May 22, 2010, 12:56:40 AM5/22/10
to Wicket Web Beans
I've got a domain model that is heavily hierarchical with collections
all over the place.

I was hoping to be able annotate each bean individually so that I
don't need to have a massive annotation on every view. What I'm
wondering is if there's some sort of 'I'm a bean in a table' context.

If I'm displaying the bean as the top level component then I'll want
to show all it's collections as tables. But the beans in the tables
also have collections which results in a huge mess of tables within
tables. It would be great if I could specify that if this bean is
part of a table row context, use this set of rules to display only
name and description.

Any way to achieve this on a bean by bean basis rather than view by
view?

Also as a side note, are bean annotations inherited? e.g. if I
annotate the name field on Parent.class with required=true will that
carry to Child.class?

--
You received this message because you are subscribed to the Google Groups "Wicket Web Beans" group.
To post to this group, send email to wicket-w...@googlegroups.com.
To unsubscribe from this group, send email to wicket-web-bea...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/wicket-web-beans?hl=en.

shadders

unread,
May 22, 2010, 3:38:38 AM5/22/10
to Wicket Web Beans
I've been looking around some more and it looks like this isn't
possible. I might suggest a neat solution would be if you can specify
a context parameter for a property. e.g.

@Bean(type = Network.class, columns = 1, tabs = {
@Tab(name = "General", propertyNames = { "id", "name",
"members" })

// Customize certain properties from above.
properties = {
@Property(name = "members", elementType = Site.class, context =
"inline")
})

so the child element would be rendered using that context if it's
defined. I'm happy to have a go at implementing this myself if you
can give me a pointer to where the annotation would be actioned?

shadders

unread,
May 22, 2010, 3:41:10 AM5/22/10
to Wicket Web Beans
or alternately you could just specify the property name the same way
the context is defined... e.g "propName[context]"

shadders

unread,
May 25, 2010, 9:26:26 PM5/25/10
to Wicket Web Beans
Just came across another related issue. One of my entity beans
contains a parent/child relationship to beans of the same class....

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.

Reply all
Reply to author
Forward
0 new messages