You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andreas Pardeike <ap...@fsys.se> on 2008/04/22 16:06:11 UTC
Wrapping a grid
Hi,
I want to wrap a grid by putting it into a custom component. But I can't
get parameter blocks to work:
In my page I have:
<t:table.Table t:source="data" name="artiklar">
<t:parameter name="firstnamecell">!</t:parameter>
</t:table.Table>
and in Table.tml:
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd
">
<t:grid source="source" row="column">
<t:body />
</t:grid>
</t:container>
If I replace <t:body /> with <t:parameter name="firstnamecell">!</
t:parameter>
it works fine, but not via the body tag. Is this a limitation, and if
so, how
do I create a workaround?
Thnx,
Andreas Pardeike
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Wrapping a grid
Posted by MohammadS <sa...@gmail.com>.
I just needed to do something similar. Basically needed to normalize the
paginated (via database) output of a grid with slightly different queries
going into the db pagination call.
I know you asked this question a long long long time ago, but thought it'll
be here for the next guys looking for a solution.
The grid component takes an "override" parameter which is supplied via
coercion. The key is to provide a different object that will provide the
grid component with the right set of "paramter" blocks.
There are a few steps.
1. Create a ContainerPropertyOverrides object that contains both the current
container's "ComponentResources" and the grid component's
"ComponentResources"
Here is a sample of the internals
private final ComponentResources parent;
private final ComponentResources self;
private final Messages messages;
public ContainerPropertyOverrides(ComponentResources resources)
{
Component container = resources.getContainer();
if(container != null)
parent = container.getComponentResources();
else
parent = null;
self = resources;
messages = resources.getContainerMessages();
}
@Override
public Block getOverrideBlock(String name)
{
if(parent != null)
{
Block b = parent.getBlockParameter(name);
if(b != null)
return b;
}
return self.getBlockParameter(name);
}
2. contribute a coercion from "ComponentResources" to your newly created
object in step 1
here is what i have
public static void contributeTypeCoercer(Configuration<CoercionTuple>
configuration)
{
configuration.add(CoercionTuple.create(ComponentResources.class,
ContainerPropertyOverrides.class,
new Coercion<ComponentResources,
ContainerPropertyOverrides>()
{
public ContainerPropertyOverrides
coerce(ComponentResources input)
{
return new ContainerPropertyOverrides(input);
}
}));
}
3. Setup your component to use all this properly
here is a snippet from my setup
public class MyGridWrapper
{
//this is just to make sure refactoring efforts in the future don't
break this
// functionality
private static final String GRID_ID="myGrid";
@Parameter(value=GRID_ID, allowNull=false)
@Property(write = false)
private ContainerPropertyOverrides overrides;
@Property
@Component(id=GRID_ID, parameters={"overrides=overrides"})
private Grid myGrid;
//stuff that sets up the source, etc etc
}
Knowing tapestry, there are probably a few other options you have to solving
the problem.
Last thing i'll mention is that you can do this without contributing a
coercion. Simply supply a default value for overrides and construct the
object yourself.
You can read about it here:
http://tapestry.apache.org/tapestry5.2-dev/guide/parameters.html
Good luck
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Wrapping-a-grid-tp2416039p3214873.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org