Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Problem with Timezome

$
0
0
We have the next problem with the timezone behavior:

Versión SmartGWTpro 4.0. Every browsers involved

On gmt-5 time zone client configuration

If we have the next EntryPoint configuration
/**
* First method executed when a GWT page is opened
*/
public void onModuleLoad() {
//SC.showConsole();
String cdSection = com.google.gwt.user.client.Window.Location.getPara meter("cdSection");
if(cdSection==null){
//This is for the initial page
}else{
FocussClientServiceCaller.getSectionConfig(this, Integer.parseInt(cdSection));
}

/**
* Set Default module config
*/
setDefaultModuleConfig();
}

/**
* Set default module configuration
*/
public void setDefaultModuleConfig(){
DateUtil.setDefaultDisplayTimezone("00:00");
DateUtil.setAdjustForDST(false);

}

Then the fetch rest data response by a date column is ok without adding hours
Error 1 : When the end user sets 28/01/2014 00:00:00 from a column date chooser into the list grid then the header column shows 27/01/2014 19:00:00 in the text field of the date chooser but in the server side is ok 28/01/2014 00:00:00

Error 2 : The same behavior in MiniDateRangeItem
The method for configuring the list grid columns is:
public void configGridAndDatasourceFields(ListGrid grid,RestDataSource dataSource,List<RolDTO> rolDTOList){

try {
DataSourceField[] dataSourceFields = new DataSourceField[window.getSectionConfig().getSelectedView().getCol umns().size()];
ListGridField[] listGridFields = new ListGridField[window.getSectionConfig().getSelectedView().getCol umns().size()];

LinkedHashMap<String,Boolean> checkBoxValueMap = Constant.getCheckBoxValueMap();
LinkedHashMap<SQLServerType,FieldType> dataTypes = Constant.getMatchSQLGWTTypes();
LinkedHashMap<SQLServerType,ListGridFieldType> listGridDataTypes = Constant.getMatchListGridTypes();
int fieldItem = 0;

for (ColumnConfig columnConfig: window.getSectionConfig().getSelectedView().getCol umns()) {
DataSourceField field = new DataSourceField();

//DataSourceField field2 = null;
//com.google.gwt.user.client.Window.alert(columnConf ig.getCdColumn());

if(checkBoxValueMap.get(columnConfig.getIsPrimaryK ey())){
this.cdColumnPK = columnConfig.getCdColumn();
}

field = new DataSourceField(columnConfig.getCdColumn(),
dataTypes.get(SQLServerType.getTypeByString(column Config.getDsType())),
columnConfig.getDsName(),
columnConfig.getColumnSize(),
!checkBoxValueMap.get(columnConfig.getIsNullable() ));

field.setPrimaryKey(checkBoxValueMap.get(columnCon fig.getIsPrimaryKey()));
if( checkBoxValueMap.get(columnConfig.getIsPrimaryKey( ))){
field.setSummaryFunction(SummaryFunctionType.COUNT );
}



boolean editPermissionEnable = window.getSectionConfig().getSelectedView().editPe rmission(columnConfig,rolDTOList);

if (editPermissionEnable) {
if(window.getSectionConfig().getSelectedView().get Indicator() != null)
field.setCanEdit(false);
else
field.setCanEdit(checkBoxValueMap.get(columnConfig .getIsEditable()));
} else {
field.setCanEdit(false);
}

if (columnConfig.getViewType().equals(Constant.LIST_T YPE.getValue())) {
field.setValueMap(columnConfig.getListColumnValueM ap());

}

if (columnConfig.getDsType().equals(SQLServerType.BOO LEAN.getType())) {
field = new DataSourceBooleanField(columnConfig.getCdColumn(), columnConfig.getDsName(), columnConfig.getColumnSize());
}

if( checkBoxValueMap.get(columnConfig.getIsPrimaryKey( ))){
//com.google.gwt.user.client.Window.alert(columnConf ig.getCdColumn()+" - "+window.getSectionConfig().getCdModule()+" - "+window.getSectionConfig().getSectionType().getCo de()+"-"+window.getSectionConfig().getSectionSubtype( ));
if((window.getSectionConfig().getDsSection().equal s(Constant.MODULE_PRODUCTION_FAMILY.getValue()))|| (window.getSectionConfig().getDsSection().equals(C onstant.MODULE_FREQUENT_CAUSES.getValue()))){
//com.google.gwt.user.client.Window.alert("entra a validar con columna"+columnConfig.getCdColumn());
//field.setHidden(true);
field.setCanView(false);
}
}

/*
* if it is Custom Fields option and the column is CDCOLUMN or IS_SYSTEM, then hide it
*/
if ((window.getSectionConfig().getDsSection().equals( Constant.MODULE_CUSTOM_FIELDS.getValue())) &&
(columnConfig.getCdColumn().equals(CustomColumnsEn um.FIELDS_CDCOLUMN.getValue()) ||
columnConfig.getCdColumn().equals(CustomColumnsEnu m.FIELDS_IS_SYSTEM.getValue()) )){
field.setCanView(false);
}

/*
* if it is Parameters option and the column is CDPARAM, then hide it
*/
if ((window.getSectionConfig().getDsSection().equals( Constant.MODULE_PARAMETERS.getValue())) &&
(columnConfig.getCdColumn().equals(Constant.PARAM_ COLUMN_CDPARAM.getValue())) ){
field.setCanView(false);
}

dataSourceFields[fieldItem] = field;

ListGridField gridField = new ListGridField();
gridField.setType(listGridDataTypes.get(SQLServerT ype.getTypeByString(columnConfig.getDsType())));
gridField.setRequired(!checkBoxValueMap.get(column Config.getIsNullable()));

if (columnConfig.getCdColumn().equals("ORDER_NOTES")) {
gridField = new ListGridField(columnConfig.getCdColumn(), columnConfig.getDsName(), columnConfig.getColumnWidth());
gridField.setAlign(Alignment.LEFT);
gridField.setValueField("");
} else {
gridField = new ListGridField(columnConfig.getCdColumn(), columnConfig.getDsName(), columnConfig.getColumnWidth());
gridField.setAlign(Alignment.LEFT);
}

if (columnConfig.getCdColumn().equals(CustomColumnsEn um.FIELDS_CDPERMISSION_EDIT.getValue())) {
gridField.setEmptyCellValue(Constant.DEFAULT_PERMI SSION.getValue());
gridField.setDefaultValue(Constant.DEFAULT_PERMISS ION.getValue());
}

/*
* If it is Location section, then, assign default Calendar Code if any
*/
if (window.getSectionConfig().getDsSection().equals(C onstant.MODULE_LOCATIONS.getValue())){
if (columnConfig.getCdColumn().equals(LocationColumns Enum.LOCATION_CDCALENDAR.getValue())) {
gridCalendarField = gridField;
FocussClientServiceCaller.getPredefinedCalendar(th is);
}
}

if((columnConfig.getDsType().equals(SQLServerType. NUMERIC.getType())&& !checkBoxValueMap.get(columnConfig.getIsPrimaryKey ())) || columnConfig.getDsType().equals(SQLServerType.DATE TIME.getType())){
gridField.setShowGridSummary(false);
}

if(columnConfig.getDsType().equals(SQLServerType.D ATETIME.getType())){
gridField.setShowGroupSummary(false);
}


if( checkBoxValueMap.get(columnConfig.getIsPrimaryKey( ))||columnConfig.getCdColumn().equals(Constant.DSF AMILY_COLUMN.getValue())
|| columnConfig.getCdColumn().equals(Constant.CDLOCAT ION_COLUMN.getValue()) ||columnConfig.getCdColumn().equals(Constant.DSCAU SE_COLUMN.getValue())
|| columnConfig.getCdColumn().equals(Constant.CDORDER _COLUMN.getValue())){

//gridField.setIncludeInRecordSummary(true);
gridField.setShowGridSummary(true);
gridField.setSummaryFunction(SummaryFunctionType.C OUNT);

//com.google.gwt.user.client.Window.alert(columnConf ig.getCdColumn()+" - "+window.getSectionConfig().getCdModule()+" - "+window.getSectionConfig().getSectionType().getCo de()+"-"+window.getSectionConfig().getSectionSubtype( ));
//if((window.getSectionConfig().getCdModule()==1)&&( window.getSectionConfig().getSectionType().getCode ().equals(Constant.WINDOW_OPEN_MODE_C.getValue())) && (window.getSectionConfig().getSectionSubtype() == null)){
if((window.getSectionConfig().getDsSection().equal s(Constant.MODULE_PRODUCTION_FAMILY.getValue()))|| (window.getSectionConfig().getDsSection().equals(C onstant.MODULE_FREQUENT_CAUSES.getValue()))){
//com.google.gwt.user.client.Window.alert("entra a validar con columna"+columnConfig.getCdColumn());
gridField.setHidden(true);
}
}

/*
* if it is Custom Fields option and the column is CDCOLUMN or IS_SYSTEM, then hide it
*/
if ((window.getSectionConfig().getDsSection().equals( Constant.MODULE_CUSTOM_FIELDS.getValue())) &&
(columnConfig.getCdColumn().equals(CustomColumnsEn um.FIELDS_CDCOLUMN.getValue()) ||
columnConfig.getCdColumn().equals(CustomColumnsEnu m.FIELDS_IS_SYSTEM.getValue()) )){
field.setCanView(false);
}

/*
* if it is Parameters option and the column is CDPARAM, then hide it
*/
if ((window.getSectionConfig().getDsSection().equals( Constant.MODULE_PARAMETERS.getValue())) &&
(columnConfig.getCdColumn().equals(Constant.PARAM_ COLUMN_CDPARAM.getValue())) ){
field.setCanView(false);
}

getFormatColumn(gridField, columnConfig);

listGridFields[fieldItem] = gridField;

grid.setSortField(fieldItem);

fieldItem++;

//PENDIENTE com.google.gwt.user.client.Window.alert(columnConf ig.getCdColumn());
}

dataSource.setFields(dataSourceFields);

grid.setFields(listGridFields);

} catch (Exception e) {
e.printStackTrace();
com.google.gwt.user.client.Window.alert("----"+e.getMessage());
throw new RuntimeException(e);
}

}


Scenario 2 :
If we have the next entryPoint configuration:
public void onModuleLoad() {
//SC.showConsole();
String cdSection = com.google.gwt.user.client.Window.Location.getPara meter("cdSection");
if(cdSection==null){
//This is for the initial page
}else{
FocussClientServiceCaller.getSectionConfig(this, Integer.parseInt(cdSection));
}

/**
* Set Default module config
*/
setDefaultModuleConfig();
}
/**
* Set default module configuration
*/
public void setDefaultModuleConfig(){
DateUtil.setDefaultDisplayTimezone("-05:00");
DateUtil.setAdjustForDST(false);

}
Then the date chooser from the list grid header and the MiniDateRangeItem(in another form) show the correct date but they send to the server side (via rest data source) a wrong date, adding 5 hours (according to the gmt-5) and the query in the server side returns fewer records than I expect. Eg 28/01/2013 15:30:50 in the client side is 28/01/2013 10:30:50 in the server side.

We will appreciate your support.

Viewing all articles
Browse latest Browse all 4756

Trending Articles