You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by wesley <we...@yahoo.co.uk> on 2008/10/01 21:25:21 UTC

formatting data output in t:grid column

hi all,

i've been wondering how i can change the format of the column data given if
the data is of type java.util.Date. the t:grid column shows my result as
yyyy-mm-dd. how about if i want to show the time as well? is there any way
that i can pass something like SimpleDataFormat to format the date? and
there is a column which is of type double that show my result in 900.0 where
i expect 900.00 with the format of #000.00. can anyone give me some
pointer/advise?

thanks.

wesley
-- 
View this message in context: http://n2.nabble.com/formatting-data-output-in-t%3Agrid-column-tp1132212p1132212.html
Sent from the Tapestry Users 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


Re: formatting data output in t:grid column

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 02 Oct 2008 03:44:35 -0300, wesley <we...@yahoo.co.uk>  
escreveu:

> this is great, thanks much for the help thiago!

You're welcome!

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: formatting data output in t:grid column

Posted by wesley <we...@yahoo.co.uk>.
this is great, thanks much for the help thiago!

regards,
wesley


Thiago H. de Paula Figueiredo wrote:
> 
> Em Wed, 01 Oct 2008 16:25:21 -0300, wesley <we...@yahoo.co.uk>  
> escreveu:
> 
>> i've been wondering how i can change the format of the column data given  
>> if the data is of type java.util.Date. the t:grid column shows my result  
>> as
>> yyyy-mm-dd. how about if i want to show the time as well? is there any  
>> way
>> that i can pass something like SimpleDataFormat to format the date? and
>> there is a column which is of type double that show my result in 900.0  
>> where
>> i expect 900.00 with the format of #000.00. can anyone give me some
>> pointer/advise?
> 
> <t:parameter name="[propertyName]Cell"> is the answer to your question. It  
> allows you to show whatever you want in a given column.
> 
> Example taken from  
> http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Grid.html:
> 
> <t:grid source="users" row="user">
> 	<t:parameter name="lastnamecell">
> 		<t:pagelink page="user/view"  
> context="user.id">${user.lastname}</t:pagelink>
> 	</t:parameter>
> </t:grid>
> 
> In your case, you would add a method in your page class that returns the  
> formatted value and then use it inside <t:parameter>
> 
> public String getDate() {
> 	return ... // formats the date
> }
> 
> <t:grid source="objects" row="object">
> 	<t:parameter name="dateCell">
> 		${date}
> 	</t:parameter>
> </t:grid>
> 
> 
> Thiago
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/formatting-data-output-in-t%3Agrid-column-tp1132212p1133253.html
Sent from the Tapestry Users 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


Re: formatting data output in t:grid column

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 01 Oct 2008 16:25:21 -0300, wesley <we...@yahoo.co.uk>  
escreveu:

> i've been wondering how i can change the format of the column data given  
> if the data is of type java.util.Date. the t:grid column shows my result  
> as
> yyyy-mm-dd. how about if i want to show the time as well? is there any  
> way
> that i can pass something like SimpleDataFormat to format the date? and
> there is a column which is of type double that show my result in 900.0  
> where
> i expect 900.00 with the format of #000.00. can anyone give me some
> pointer/advise?

<t:parameter name="[propertyName]Cell"> is the answer to your question. It  
allows you to show whatever you want in a given column.

Example taken from  
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Grid.html:

<t:grid source="users" row="user">
	<t:parameter name="lastnamecell">
		<t:pagelink page="user/view"  
context="user.id">${user.lastname}</t:pagelink>
	</t:parameter>
</t:grid>

In your case, you would add a method in your page class that returns the  
formatted value and then use it inside <t:parameter>

public String getDate() {
	return ... // formats the date
}

<t:grid source="objects" row="object">
	<t:parameter name="dateCell">
		${date}
	</t:parameter>
</t:grid>


Thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org