pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Swan <andrew.i.s...@gmail.com>
Subject Passing parameters to wtkx:include?
Date Sun, 25 Apr 2010 23:44:39 GMT

I'm a first-time poster and new Pivot user, so be gentle!

I need to create a custom UI component that accepts a number of parameters
(e.g. an image URL and some label text), similar to how JSP tags can accept

The Pivot docs for the "wtkx:include" tag say:

"The <wtkx:include> tag allows a WTKX file to embed content defined in an
external WTKX file as if it was defined in the source file itself. This is
useful for ... defining reusable content templates".

I was hoping that I could define my component in a WTKX file using standard
Pivot components (e.g. a TextInput) and pass it one or more parameters; for
example my reusable template called "row.wtkx" might contain a row with an
image and a text field, like this (where the ${xxx} bits are the

<TablePane.Row xmlns="org.apache.pivot.wtk">
    <ImageView image="@images/${image_url}" />
    <TextInput text="${title}" />

I could then reuse this component within a TablePane as follows:

        <Label text="Painting"/>
        <Label text="Title"/>
    <wtkx:include src="row.wtkx" image_url="mona_lisa.jpg" title="Mona
    <wtkx:include src="row.wtkx" image_url="pearl_earring.jpg" title="Girl
with a Pearl Earring"/>
    <wtkx:include src="row.wtkx" image_url="melting_clocks.jpg"
title="Melting Clocks"/>

I've made up the ${...} syntax myself just to show what I'm trying to do.
Also, there could be other ways to pass the parameter values other than
using attributes of the "wtkx:include" tag itself, e.g. pass a JSON-style
map called say "args".

The ability to pass parameters like this would make the include tag much
more powerful, e.g. in my case allow me to eliminate a lot of duplication
between the table row declarations.

Or is "wtkx:include" not the right way to be doing this?


View raw message