Fixed Date support for Cell

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-widgetx@95632 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-05-13 13:39:50 +00:00 committed by Giancarlo Panichi
parent 9c23a014de
commit c95d6797ec
2 changed files with 25 additions and 2 deletions

View File

@ -268,9 +268,16 @@ public class TabularDataXGridPanel extends ContentPanel {
.getCell());
DataRowColumnConfig<?> cSelected = (DataRowColumnConfig<?>) colSelected;
ColumnDefinition cdSelected = cSelected.getDefinition();
String cellValue = row.getFieldAsText(cdSelected
String cellValue;
if(cdSelected.getColumnDataType().compareTo("Date")==0){
cellValue = row.getFieldAsDate(cdSelected
.getColumnLocalId());
} else {
cellValue = row.getFieldAsText(cdSelected
.getColumnLocalId());
}
String columnIdValue = row.getFieldAsText(columnIdSelected
.getColumnLocalId());

View File

@ -3,12 +3,15 @@
*/
package org.gcube.portlets.user.tdwx.client.config;
import java.util.Date;
import java.util.Map;
import org.gcube.portlets.user.tdwx.shared.model.ColumnKey;
import org.gcube.portlets.user.tdwx.shared.model.DataRow;
import com.google.gwt.i18n.client.DateTimeFormat;
/**
*
* @author "Giancarlo Panichi"
@ -54,6 +57,19 @@ public class Row {
return String.valueOf(value);
}
/**
* Returns the specified field as text value.
* @param fieldId the field id.
* @return the text value.
*/
public String getFieldAsDate(String fieldId)
{
Date value = (Date)getField(fieldId);
DateTimeFormat sdf= DateTimeFormat.getFormat("yyyy-MM-dd");
return sdf.format(value);
}
/**
* Returns the specified field as request value type T.
* If a wrong type is specified a {@link ClassCastException} will be throw.