Mind Bridge - Thanks for you reply. I updated my code to the follow the pattern you outlined.
I'm getting an "ognl.NoSuchPropertyException" when it tries to load the columns. It shows "$SegmentDetail_14.lastPurchase" with the error... SegmentDetail is my page, the lastPurchase should be coming from the items in the "members" list from the page, not the page directly. It seems to be trying to load the column from my page, instead of the from the source (ie, <binding name="source" value="ognl:members" />) Any ideas? I wonder if it's related to the fact that I'm using this in a page and not a component. Thanks, Joe -----Original Message----- From: Mind Bridge [mailto:[EMAIL PROTECTED] Sent: Friday, July 22, 2005 6:20 PM To: Tapestry users Subject: Re: Tapestry4 contrib:Table format & sort Hi, The below explanation is also related to another message that appeared on the list a bit earlier. It is important to remember the below principle when working with contrib:Table (and I am making a point to emphasize it in the docs). There are two distinct aspects of a table column: - The first one is the value used for sorting. This is the OGNL expression given in the 'columns' string. - The second one is the visual representation of the column. By default that is simply the string representation of the value used for sorting, as the two often coincide. Nevertheless, it is possible to define a more elaborate representation by declaring a Block with a name <column_id>ColumnValue. To apply those principles, here is how I would approach what you want to do: In the .page/.jwc: <binding name="columns"> accountNumber, firstName, lastPurchase:amount, visitCnt, lastDate </binding> In the .html: <span jwcid="[EMAIL PROTECTED]"> $<span jwcid="@Insert" value="formatCurrency(components.membersTableView.tableRow.amount)"/> </span> <span jwcid="[EMAIL PROTECTED]"> <span jwcid="@Insert" value="formatNumber(components.membersTableView.tableRow.visitCnt)"/> </span> <span jwcid="[EMAIL PROTECTED]"> <span jwcid="@Insert" value="formatDate(components.membersTableView.tableRow.lastDate)"/> </span> In .properties: accountNumber=Account Number firstName=First Name lastPurchase=Last Avg Purchase visitCnt=Number Visits lastDate=Last Date In that way the columns will be sorted properly, there is more freedom to make them look like it is needed, and column titles can contain random symbols and are internationalizable. Please note that the code has not been tested and may contain bugs here and there -- best to just extract the principles from it. There are other less verbose ways to do the above (e.g. with a 'row' property), but that is an optimization. -mb Joe Goldwasser wrote: >I'm trying to get the contrib:table to format my data (date, currency, >numbers, etc) then be able to sort it. > >I'm using Tapestry 4 beta 2. > >I'm able to get it to format properly, probably not the "correct" way - >I use a method from my bean that is being rendered in my table to >format the value and return it as a String. The problem I have now is >that when I sort, I'm sorting strings, when it really needs to be >sorting number, dates, etc. > >Here's what I have in my .page file: > > <component id="membersTableView" type="contrib:TableView"> > <binding name="source" value="ognl:members" /> > <binding name="columns"> > Account Number:accountNumber, First Name:firstName, Last > Avg Purchase:"$" + formatCurrency(amount), Number >Visits:formatNumber(visitCnt), > Last Date:formatDate(lastDate) > </binding> > </component> > > <component id="membersTableColumns" type="contrib:TableColumns" /> > <component id="membersTablePages" type="contrib:TablePages" /> > <component id="membersTableFormRows" > type="contrib:TableRows"></component> > > <component id="membersTableValues" type="contrib:TableValues" /> > >The methods (formatCurrency, formatNumber, formatDate) are in my "Member" >bean that the table is rendering. So this works for the format, but >when I sort by clicking on the column headers they are now strings, >which doesn't work as needed. > >Any advice is greatly appreciated. > >Thanks, >Joe > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
