On Mon, 07 Jul 2014 10:00:55 -0300, Davide Vecchi <d...@amc.dk> wrote:

Hi,

Hi!

Thanks for the quick feedback ! Yes, I would like to make this change so that it is used by every grid in my application.

So what you want is to override the property viewing blocks used by BeanModel-based components (in this case, Grid and BeanDisplay) for some Tapestry types (which are just strings, not having a class representing them. DataTypeConstants provides constants for the types Tapestry recognizes out-of-the-box). Another question: do you want to do this for every column, regardless of the type of its value (String, Date, boolean, etc) or not? If yes, then you may use Tapestry DOM rewriting. If not, I'll sketch a solution for you, below.

I don't have time to make a tutorial right now, so I'll suggest you to take a look at PropertyDisplayBlocks (the Tapestry page that contains the blocks Grid and BeanDisplay use to render the columns in Grid),

Quick attempt, not tested, specifically for columns of type String, to explain what you need to do:

1) Create a MyPropertyDisplayBlocks (name doesn't matter much) page and its template.

2) This will be the template:

<t:container xml:space="default" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
    <t:block id="longtext">
        <!-- render here whatever you want -->
    </t:block>
</t:container>

3) In MyPropertyDisplayBlocks.java, you'll need this:

@Environmental
private PropertyOutputContext context; // this is the way you get the value to be rendered.

context.getPropertyValue() will provide you the value of the column.

4) Override the out-of-the-box configured block. In your AppModule, add this:

public static void contributeBeanBlockSource(Configuration<BeanBlockContribution> configuration) { configuration.override(new DisplayBlockContribution(DataTypeConstants.LONG_TEXT, "MyPropertyDisplayBlocks", "longtext");
}

--
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

Reply via email to