Search code examples
javadatagridgridjavabeanstapestry

Tapestry5 - squash bean properties into one grid cell


i don't know if this is possible to do using Tapestry5. I would like to squash some bean properties into only one grid cell. For example, take a look at this bean :

public class BeanExample {
       private int x;
       private int y;
       private String string;
       //getters, setters etc..
}

If i would show this bean using a default grid it will generate something like this :

    X   |   Y    |   STRING
___________________________
    0   |   1    |   hello
    1   |   4    |   by

What i would like to do is to "squash" two properties into only one and show it at FrontEnd like this :

    X   |   Y+STRING
___________________________
    0   |   1 / hello
    1   |   4 / by

Any idea?


Solution

  • Here's an example of hiding the string column and providing a custom block for the y cells. See the grid javadoc for more info

    <t:grid source="rows" exclude="string" row="current">
        <p:yCell>
            ${current.y} / ${current.string}
        </p:yCell>
    </t:grid>