You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Matt Preston <ma...@knowledgeview.co.uk> on 2004/03/25 17:49:35 UTC
Table confusion...
Hi,
I'm trying to create a table where I can specify a custom component
(with a template) to render the column values. I've read the example in
the component specification and have come up with the following:
> <!-- Results Data -->
> <span jwcid="resultstableview@contrib:TableView"
> source="ognl:results"
> columns="ognl:columns"
> element="span"
> pageSize="20"
> pagesDisplayed="3">
>
> <div class="result-page-navigation">
> <span jwcid="@contrib:TablePages" />
> </div>
>
> <div class="result-content-div">
> <table cellspacing="0">
> <tr jwcid="@contrib:TableRows">
> <td jwcid="itemcell@contrib:TableValues" />
> </tr>
> </table>
> </div>
>
> <div class="result-page-navigation">
> <span jwcid="@contrib:TablePages" />
> </div>
> </span>
In the page class:
* getResults() returns a list of domain objects.
* getColumns() returns an ITableColums[] containing SimpleTableColumn
Objects where I have set a custom ValueRendererSource.
This works pretty well, but I have to manually write the html via a
render method. It seems like I should be able to use a proper component
& template, but I just can't see how to connect it all up probably.
Can anyone point me in the right direction?
Thanks,
Matt (Tapestry Newbie)
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Table confusion...
Posted by Mindbridge <mi...@yahoo.com>.
Hi,
Nice use of the Table components :)
> This works pretty well, but I have to manually write the html via a
> render method. It seems like I should be able to use a proper component
> & template, but I just can't see how to connect it all up probably.
You can use a Block in the page/component where you use the table (or in a
different place if needed) to describe how the column should look like.
There are a couple of ways to do that:
(1) Similar to what you are doing now:
.html:
<span jwcid="userBlock@Block">
....
</span>
.java:
Block userBlock = (Block) getComponent("userBlock")
ITableRendererSource userRendererSource = new
BlockTableRendererSource(userBlock);
userColumn.setValueRendererSource(userRendererSource);
(2) Automate the above a little bit. Assume the id of the column is 'user'
.html:
<span jwcid="userColumnValue@Block">
....
</span>
.java:
userColumn.loadSettings(this);
Approach (2) will do the same as approach (1) and also use the component
translation strings to set the column's display name. This is what is
automatically done when you declare the columns as a string and what is
described in the Table documentation
(http://jakarta.apache.org/tapestry/doc/ComponentReference/contrib.Table.htm
l). Also see the examples if necessary.
In both of those ways you can declare how the column should look like in
HTML rather than in Java.
-mb
----- Original Message -----
From: "Matt Preston" <ma...@knowledgeview.co.uk>
To: <ta...@jakarta.apache.org>
Sent: Thursday, March 25, 2004 6:49 PM
Subject: Table confusion...
> Hi,
>
> I'm trying to create a table where I can specify a custom component
> (with a template) to render the column values. I've read the example in
> the component specification and have come up with the following:
>
> > <!-- Results Data -->
> > <span jwcid="resultstableview@contrib:TableView"
> > source="ognl:results"
> > columns="ognl:columns"
> > element="span"
> > pageSize="20"
> > pagesDisplayed="3">
> >
> > <div class="result-page-navigation">
> > <span jwcid="@contrib:TablePages" />
> > </div>
> >
> > <div class="result-content-div">
> > <table cellspacing="0">
> > <tr jwcid="@contrib:TableRows">
> > <td jwcid="itemcell@contrib:TableValues" />
> > </tr>
> > </table>
> > </div>
> >
> > <div class="result-page-navigation">
> > <span jwcid="@contrib:TablePages" />
> > </div>
> > </span>
>
>
> In the page class:
> * getResults() returns a list of domain objects.
> * getColumns() returns an ITableColums[] containing SimpleTableColumn
> Objects where I have set a custom ValueRendererSource.
>
> This works pretty well, but I have to manually write the html via a
> render method. It seems like I should be able to use a proper component
> & template, but I just can't see how to connect it all up probably.
>
> Can anyone point me in the right direction?
>
> Thanks,
> Matt (Tapestry Newbie)
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org