You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Christian Mittendorf <ch...@freenet.de> on 2005/11/22 13:58:40 UTC
Howto format date values within contrib:Table?
Hello!
I've using a plain Table component from the contrib lib and I'd like
to for format the date values of one column. How can I accomplish
that? Does anybody have a nice example ready?
Christian
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Howto format date values within contrib:Table?
Posted by Andreas Andreou <an...@di.uoa.gr>.
In the columns parameter leave the field as date
<binding name="columns" value="literal:1:ID:id, 2:Start Datum:date"/>
In your html template, add this span:
<span jwcid="dateColumnValue@Block">
<span jwcid="@Insert"
value="ognl:@de.cmittendorf.tools.Formatter@formatDate(components.myTable.tableRow.date)"
/>
</span>
This block is for customizing the appearance of a column - you can put
links, images, etc.
Sorting is always done with the value set in the 'columns' parameter.
Christian Mittendorf wrote:
>
> Am 22.11.2005 um 14:04 schrieb Jesse Kuhnert:
>
>> It's pretty easy to do :)
>
>
> Yepp, it really was. Thanks for your hint. I created a Formatter
> utility class that I used for my ognl expression:
>
> <binding name="columns" value="literal:1:ID:id, 2:Start
> Datum:@de.cmittendorf.tools.Formatter@formatDate(date)"/>
>
> Works really nice, except... the automatic sorting does no longer
> work, because the table is sorting the formatted Strings (using
> german date formatting) instead of the date objects. The result will
> look like this:
>
> ID DATE 'v'
> 1 24.11.2005
> 4 19.10.2005
> 6 11.11.2005
>
> Does anybody have a hint how to format a date while keeping the sorting?
>
> Christian
>
>
>
>
>> On 11/22/05, Christian Mittendorf <ch...@freenet.de>
>> wrote:
>>
>>> Hello!
>>>
>>> I've using a plain Table component from the contrib lib and I'd like
>>> to for format the date values of one column. How can I accomplish
>>> that? Does anybody have a nice example ready?
>>>
>>> Christian
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>
>
> ---------------------------------------------------------------------
> 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
Re: Howto format date values within contrib:Table?
Posted by Christian Mittendorf <ch...@freenet.de>.
Am 22.11.2005 um 14:04 schrieb Jesse Kuhnert:
> It's pretty easy to do :)
Yepp, it really was. Thanks for your hint. I created a Formatter
utility class that I used for my ognl expression:
<binding name="columns" value="literal:1:ID:id, 2:Start
Datum:@de.cmittendorf.tools.Formatter@formatDate(date)"/>
Works really nice, except... the automatic sorting does no longer
work, because the table is sorting the formatted Strings (using
german date formatting) instead of the date objects. The result will
look like this:
ID DATE 'v'
1 24.11.2005
4 19.10.2005
6 11.11.2005
Does anybody have a hint how to format a date while keeping the sorting?
Christian
> On 11/22/05, Christian Mittendorf <ch...@freenet.de>
> wrote:
>> Hello!
>>
>> I've using a plain Table component from the contrib lib and I'd like
>> to for format the date values of one column. How can I accomplish
>> that? Does anybody have a nice example ready?
>>
>> Christian
>>
>> ---------------------------------------------------------------------
>> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Howto format date values within contrib:Table?
Posted by Jesse Kuhnert <jk...@gmail.com>.
It's pretty easy to do :)
This example is a little out of context, but the columns="" statement
is evaluated by ognl, so I believe you can just call whatever method
you need to to format things...Like the startTime value below could
probably be replaced by a method call to your page to some
"formatFoo(Date value)" method via "!start:Start
Time:formatFoo(startTime)".
<fieldset>
<legend><span class="" jwcid="@Insert"
value="message:title.current.cases"/></legend>
<label>
<table jwcid="tableView@contrib:TableView" cellspacing="0" class="searchTable"
source="ognl:cases"
columns="!name:Patient Name:caseName, !start:Start
Time:startTime, !active:Locked:locked(), !location:Location:location,
!region:Region:region" element="table">
<tr>
<span jwcid="tableColumns"/>
</tr>
<tr jwcid="tableRows@contrib:TableRows" class="ognl:beans.evenOdd.next">
<td jwcid="tableValues@contrib:TableValues"/>
</tr>
</table>
</label>
</fieldset>
You can also define the column model via code this way:
/**
* Get the column model for the search page.
* @return Column model
*/
public ITableColumnModel getColumnModel() {
try {
String[] colList = { "patient.name", "Name", "patient.name", "true",
"startTime", "Start", "startTime", "true",
"endTime", "End", "endTime", "true" };
ExpressionTableColumnModel colModel =
new ExpressionTableColumnModel(colList,
getExpressionEvaluator());
return colModel;
} catch (Throwable t) {
log.error("error", t);
return null;
}
}
Which may make it easier to see how these things get used.
jesse
On 11/22/05, Christian Mittendorf <ch...@freenet.de> wrote:
> Hello!
>
> I've using a plain Table component from the contrib lib and I'd like
> to for format the date values of one column. How can I accomplish
> that? Does anybody have a nice example ready?
>
> Christian
>
> ---------------------------------------------------------------------
> 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
Re: Howto format date values within contrib:Table?
Posted by Shing Hing Man <ma...@yahoo.com>.
Something like this in the html template:
<span jwcid="accessTimeColumnValue@Block">
<span jwcid="@Insert"
value="ognl:dataRow.accessTime"
format="ognl:dateFormater" />
</span>
In your page specification file :
<property name="dateFormater"
initial-value="new
java.text.SimpleDateFormat('EEE, d MMM yy HH:mm
\'GMT\'Z')"/>
The above is for Tapestry 4.
In case you did not know, John Reynolds has an
excellent tutorial on the table component.
https://tapestrywebcomponentexamples.dev.java.net/
I think it is written in Tapestry 3, but it is still
very much relevant in Tapestry 4.
Shing
--- Christian Mittendorf
<ch...@freenet.de> wrote:
> Hello!
>
> I've using a plain Table component from the contrib
> lib and I'd like
> to for format the date values of one column. How can
> I accomplish
> that? Does anybody have a nice example ready?
>
> Christian
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
>
>
Home page :
http://uk.geocities.com/matmsh/index.html
___________________________________________________________
Yahoo! Model Search 2005 - Find the next catwalk superstars - http://uk.news.yahoo.com/hot/model-search/
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org