You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by C Jennings <co...@yahoo.com> on 2010/10/24 04:23:09 UTC
Displaying Date (YYYY-MM-dd) In a Table?
Hello -
I am running into a problem when trying to display a Date pattern (YYYY-MM-dd)
on an org.apache.click.control.Table
.
I have a HtmlForm that uses the DateField type for 2 fields. Once the form is
populated and committed to the database, I return to the main page and invoke a
Decorator pattern (below) to display the populated date fields from the
HtmlForm.
However, when I cast that row object to MyProfile, the values for minListDate
and maxListDate show the time values again (all zeros). However, even though it
works, it unfortunately shows Date and Time values on my table. I set their data
type to java.Util.Date to match what I was using in the HtmlForm for DateField.
As such, this gives me the time values as well.
Does anyone have any input here on how I could just display the Date value on
that table? I have tried changing the datatypes to use java.sql.Date package.
This worked fine for displaying the Date on my table but then it caused problems
with using DateField which relies on the java.Util.Date package.
Anyways hope I have explained this somewhat clearly. I've spent some time trying
various parsing techniques with no luck.
Many thanks!
Conor
myTable = new Table("myTable");
myTable.addColumn(new Column("minListDate"));
myTable.addColumn(new Column("maxListDate"));
Column actionColumn = new Column("Action", "Edit | Delete");
actionColumn.setDecorator(new Decorator() {
public String render(Object row, Context context) {
MyProfile myProfile = (MyProfile) row;
String id = String.valueOf(myProfile.getId());
editYourProfileLink.setParameter("id", id);
editYourProfileLink.setImageSrc("images/add.gif");
editYourProfileLink.setTitle("Edit Your Profile");
deleteYourProfileLink.setValue(id);
deleteYourProfileLink.setImageSrc("images/cross.png");
deleteYourProfileLink.setTitle("Delete Your Profile");
return editYourProfileLink.toString() + " | " +
deleteYourProfileLink.toString();
}
});
myTable.addColumn(actionColumn);
<etc>
Re: Displaying Date (YYYY-MM-dd) In a Table?
Posted by C Jennings <co...@yahoo.com>.
Bob -
Thank you very much (once again) for offering up your tremendous assistance.
I am amazed and delighted at how responsive and helpful the Apache Click User
Forum has been over the past year. It is truly wonderful how helpful you (and
many others have been) on this board.
Many thanks for Apache Click!!!
Regards -
Conor
----- Original Message ----
From: Bob Schellink <sa...@gmail.com>
To: user@click.apache.org
Sent: Sat, October 23, 2010 10:42:06 PM
Subject: Re: Displaying Date (YYYY-MM-dd) In a Table?
Hi,
You can format your column[1] display as follows:
Column dateColumn = new Column("minListDate");
dateColumn.setFormat("{0,date,dd MMM yyyy}");
table.addColumn(dateColumn);
Kind regards,
Bob
[1]: http://click.apache.org/docs/click-api/org/apache/click/control/Column.html
On 24/10/2010 13:23, C Jennings wrote:
> Hello -
> I am running into a problem when trying to display a Date pattern (YYYY-MM-dd)
> on an org.apache.click.control.Table
> .
> I have a HtmlForm that uses the DateField type for 2 fields. Once the form is
> populated and committed to the database, I return to the main page and invoke a
>
> Decorator pattern (below) to display the populated date fields from the
> HtmlForm.
>
> However, when I cast that row object to MyProfile, the values for minListDate
> and maxListDate show the time values again (all zeros). However, even though it
>
> works, it unfortunately shows Date and Time values on my table. I set their
>data
>
> type to java.Util.Date to match what I was using in the HtmlForm for DateField.
>
> As such, this gives me the time values as well.
>
> Does anyone have any input here on how I could just display the Date value on
> that table? I have tried changing the datatypes to use java.sql.Date package.
> This worked fine for displaying the Date on my table but then it caused
>problems
>
> with using DateField which relies on the java.Util.Date package.
>
> Anyways hope I have explained this somewhat clearly. I've spent some time
>trying
>
> various parsing techniques with no luck.
>
> Many thanks!
>
> Conor
>
> myTable = new Table("myTable");
>
> myTable.addColumn(new Column("minListDate"));
> myTable.addColumn(new Column("maxListDate"));
>
> Column actionColumn = new Column("Action", "Edit | Delete");
>
> actionColumn.setDecorator(new Decorator() {
>
> public String render(Object row, Context context) {
>
> MyProfile myProfile = (MyProfile) row;
> String id = String.valueOf(myProfile.getId());
>
> editYourProfileLink.setParameter("id", id);
> editYourProfileLink.setImageSrc("images/add.gif");
> editYourProfileLink.setTitle("Edit Your Profile");
>
> deleteYourProfileLink.setValue(id);
> deleteYourProfileLink.setImageSrc("images/cross.png");
> deleteYourProfileLink.setTitle("Delete Your Profile");
>
> return editYourProfileLink.toString() + " | " +
> deleteYourProfileLink.toString();
> }
> });
>
> myTable.addColumn(actionColumn);
>
> <etc>
>
>
>
>
Re: Displaying Date (YYYY-MM-dd) In a Table?
Posted by Bob Schellink <sa...@gmail.com>.
Hi,
You can format your column[1] display as follows:
Column dateColumn = new Column("minListDate");
dateColumn.setFormat("{0,date,dd MMM yyyy}");
table.addColumn(dateColumn);
Kind regards,
Bob
[1]: http://click.apache.org/docs/click-api/org/apache/click/control/Column.html
On 24/10/2010 13:23, C Jennings wrote:
> Hello -
> I am running into a problem when trying to display a Date pattern (YYYY-MM-dd)
> on an org.apache.click.control.Table
> .
> I have a HtmlForm that uses the DateField type for 2 fields. Once the form is
> populated and committed to the database, I return to the main page and invoke a
> Decorator pattern (below) to display the populated date fields from the
> HtmlForm.
>
> However, when I cast that row object to MyProfile, the values for minListDate
> and maxListDate show the time values again (all zeros). However, even though it
> works, it unfortunately shows Date and Time values on my table. I set their data
> type to java.Util.Date to match what I was using in the HtmlForm for DateField.
> As such, this gives me the time values as well.
>
> Does anyone have any input here on how I could just display the Date value on
> that table? I have tried changing the datatypes to use java.sql.Date package.
> This worked fine for displaying the Date on my table but then it caused problems
> with using DateField which relies on the java.Util.Date package.
>
> Anyways hope I have explained this somewhat clearly. I've spent some time trying
> various parsing techniques with no luck.
>
> Many thanks!
>
> Conor
>
> myTable = new Table("myTable");
>
> myTable.addColumn(new Column("minListDate"));
> myTable.addColumn(new Column("maxListDate"));
>
> Column actionColumn = new Column("Action", "Edit | Delete");
>
> actionColumn.setDecorator(new Decorator() {
>
> public String render(Object row, Context context) {
>
> MyProfile myProfile = (MyProfile) row;
> String id = String.valueOf(myProfile.getId());
>
> editYourProfileLink.setParameter("id", id);
> editYourProfileLink.setImageSrc("images/add.gif");
> editYourProfileLink.setTitle("Edit Your Profile");
>
> deleteYourProfileLink.setValue(id);
> deleteYourProfileLink.setImageSrc("images/cross.png");
> deleteYourProfileLink.setTitle("Delete Your Profile");
>
> return editYourProfileLink.toString() + " | " +
> deleteYourProfileLink.toString();
> }
> });
>
> myTable.addColumn(actionColumn);
>
> <etc>
>
>
>
>