On Wed, 24 Sep 2014 10:59:50 -0300, Chris Mylonas <ch...@opencsta.org>
wrote:
Hi Daniel,
Hi, guys!
Disclaimer: I don't pretend to know anything about BeanModels,
BeanModelSources and Grids.....however
I know a thing or two about them. :)
Sounds like a bit of reflection to get field names on your POJOs and
BeanModel.exclude().exclude().exclude().....exclude() or a bit of
recursion til the end of an arraylist of empty/whitespace field values
is reached.
Actually, no reflection needed. BeanModelSource already does this part for
you.
Not tested code below. Code could be more concise, but I wanted to show
the parts involved.
@Property
private Object object; // actually, it can be any type
@Inject
private BeanModelSource beanModelSource;
@Inject
private Messages messages;
BeanModel getModel() {
BeanModel beanModel =
beanModelSource.createDisplayModel(object.getClass(), messages);
List<String> propertyNames = beanModel.getPropertyNames();
for (String propertyName : propertyNames) {
PropertyModel propertyModel = beanModel.get(propertyName);
PropertyConduit conduit = propertyModel.getConduit();
Object propertyValue = conduit.get(object);
if (propertyValue == null) { // or any other logic you want
beanModel.remove(propertyName)
}
}
}
<t:beandisplay object="object" model="model"/>
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org