Thiago, that was perfect! I had in-fact gone down the reflection route and was getting into trouble since the propertyNames aren't really the method or field names. I forgot about using conduits manually that way!
Your code works as is, but I still stuck it in a custom MeaningfulBeanDisplay component in it's setupRender method, because I don't want to write this logic for every model for every POJO. Sometimes I'll have 5-10 of these POJOs on one page. Great job Thiago, thank you thank you! On Wed, Sep 24, 2014 at 10:52 AM, Thiago H de Paula Figueiredo < thiag...@gmail.com> wrote: > 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 > >