Missed one question - so the entire rest of the system should be local time?
Announcement
Collapse
No announcement yet.
X
-
There's not currently an option to display the calculated date in a timezone different from the entered date. A few options:
1. display the UTC date with an additional control, or at a different point in the user interaction, instead of overriding the default calculated date display. Seeing consistent times between data entry and resulting value helps users to understand what the relative date interface is doing. But you could use showCalculatedDateField:false if you decide to suppress the default display.
2. use the Feature Sponsorship program to have a feature added allowing the built-in display to be in a different timezone
Comment
-
Originally posted by Isomorphic View PostThere's not currently an option to display the calculated date in a timezone different from the entered date. A few options:
1. display the UTC date with an additional control, or at a different point in the user interaction, instead of overriding the default calculated date display. Seeing consistent times between data entry and resulting value helps users to understand what the relative date interface is doing. But you could use showCalculatedDateField:false if you decide to suppress the default display.
2. use the Feature Sponsorship program to have a feature added allowing the built-in display to be in a different timezone
Thanks for responding. A different control may be the way to go such as a StaticTextItem.
Comment
-
Fixes for everything but the sizing warnings you reported were already present in the build from March 12 - you said you were testing with that build, but you showed warnings which were removed specifically in that build, so it looks like you were using an earlier version.
Irrespective, please retest with the latest nightly - if you still see issues, we will need to see a precise list of steps, what you're doing in what order, whether you're clearing the value out in between, what you're seeing happen and what *exactly* you expect to be seeing.
Your sample seems to work fine for us, but you might also try removing your changed handler as a test - it's possible it could be interfering with internal value parsing
Comment
-
Originally posted by Isomorphic View PostFixes for everything but the sizing warnings you reported were already present in the build from March 12 - you said you were testing with that build, but you showed warnings which were removed specifically in that build, so it looks like you were using an earlier version.
Irrespective, please retest with the latest nightly - if you still see issues, we will need to see a precise list of steps, what you're doing in what order, whether you're clearing the value out in between, what you're seeing happen and what *exactly* you expect to be seeing.
Your sample seems to work fine for us, but you might also try removing your changed handler as a test - it's possible it could be interfering with internal value parsing
However, the sizing warnings still exist. Reproduction steps with code:
1. Click the radio button called "Just Enable"
2. Select relative date of "Current day of next week"
3. End date relative date item will show error icon and sizing warnings appear. I can repeat this several times.
I am using SmartClient Version: v8.3p_2013-03-14/LGPL Development Only (built 2013-03-14) and FF 17.0.2 ESR on Windows 7, en-us locale. I have done a gwt-recompile, cleaned and re-built the project in Eclipse.
Code:package com.corp.smartgwt.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.i18n.client.DateTimeFormat; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.util.DateUtil; import com.smartgwt.client.widgets.form.fields.RadioGroupItem; import com.smartgwt.client.widgets.form.fields.RelativeDateItem; import com.smartgwt.client.util.DateDisplayFormatter; import com.smartgwt.client.util.DateParser; import com.smartgwt.client.util.SC; import com.smartgwt.client.data.RelativeDate; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.types.TimeUnit; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.form.fields.events.ShowValueEvent; import com.smartgwt.client.widgets.form.fields.events.ShowValueHandler; import com.smartgwt.client.widgets.form.validator.DateRangeValidator; import java.util.Date; import java.util.LinkedHashMap; public class SmartGwt implements EntryPoint { private RelativeDateItem theStartDateItem; private RelativeDateItem theEndDateItem; private static String DATE_FORMAT = "dd.MMM.yyyy HH:mm z"; private static String RADIOGROUP_NAME = "radiogroup1"; private RadioGroupItem theFilterRadioGroup; private static final String RB1_LABEL_TEXT = "Disable"; private static final String RB2_LABEL_TEXT = "Set Value Now and Enable"; private static final String RB3_LABEL_TEXT = "Just Enable"; private final static LinkedHashMap<String, String> theDatePresets = new LinkedHashMap<String, String>(); static { theDatePresets.put("$now", "Now"); theDatePresets.put("$today", "Today"); theDatePresets.put("$yesterday", "Yesterday"); theDatePresets.put("$tomorrow", "Tomorrow"); theDatePresets.put("-1w", "Current day of last week"); theDatePresets.put("+1w", "Current day of next week"); theDatePresets.put("+1m", "Current day of next month"); theDatePresets.put("-1m", "Current day of last month"); } @Override public void onModuleLoad() { HLayout layout = new HLayout(); DynamicForm form = new DynamicForm(); form.setFields(getFilterRadioGroup(), getStartDateItem(), getEndDateItem()); layout.addMember(form); layout.draw(); } /** * This method returns a RadioGroupItem consisting of None, * Image Date, and Load Date. It uses lazy initialization. * @return RadioGroupItem */ private RadioGroupItem getFilterRadioGroup() { if (theFilterRadioGroup == null) { theFilterRadioGroup = new RadioGroupItem(RADIOGROUP_NAME); theFilterRadioGroup.setValueMap(RB1_LABEL_TEXT, RB2_LABEL_TEXT, RB3_LABEL_TEXT); theFilterRadioGroup.setShowTitle(false); theFilterRadioGroup.setDefaultValue(RB1_LABEL_TEXT); theFilterRadioGroup.setGlobalTabIndex(21); getStartDateItem().setDisabled(true); getEndDateItem().setDisabled(true); theFilterRadioGroup.addChangedHandler(new ChangedHandler() { /* * This method should fire anytime a user changes the radio button selection. */ @Override public void onChanged(ChangedEvent event) { if (theFilterRadioGroup.getValueAsString().equals(RB1_LABEL_TEXT)) { getStartDateItem().setDisabled(true); getEndDateItem().setDisabled(true); } else if (theFilterRadioGroup.getValueAsString().equals(RB2_LABEL_TEXT)) { getStartDateItem().enable(); getEndDateItem().enable(); getStartDateItem().setValue("$now"); } else { getStartDateItem().enable(); getEndDateItem().enable(); } } }); } return theFilterRadioGroup; } private void changeDateFormat() { DateUtil.setDefaultDisplayTimezone("-04:00"); DateUtil.setShortDatetimeDisplayFormatter(new DateDisplayFormatter() { public String format(Date date) { if(date == null) { return null; } else { final DateTimeFormat dateFormatter = DateTimeFormat.getFormat(DATE_FORMAT); return dateFormatter.format(date); } } }); // It is a requirement that we implement a custom date parser or the onChanged event // will not fire. DateUtil.setDateParser(new DateParser() { public Date parse(String dateString) { final DateTimeFormat format = DateTimeFormat.getFormat(DATE_FORMAT); return format.parse(dateString); } }); } private RelativeDateItem getStartDateItem() { if (theStartDateItem == null) { changeDateFormat(); theStartDateItem = new RelativeDateItem("start_date"); theStartDateItem.setTitle("Start"); theStartDateItem.setShowFutureOptions(false); theStartDateItem.setShowPastOptions(true); theStartDateItem.setTimeUnitOptions(getTimeOptions()); theStartDateItem.setDefaultQuantity(1); theStartDateItem.setValue(new RelativeDate("-1d")); theStartDateItem.setPresetOptions(theDatePresets); theStartDateItem.setOverflow(Overflow.VISIBLE); theStartDateItem.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { // Test if this is a relative date selection so we can save it that way RelativeDate relDate = theStartDateItem.getRelativeDate(); Date startDate = (Date)theStartDateItem.getValue(); Date endDate = (Date)getEndDateItem().getValue(); // Per the JavaDoc, compareTo returns less than 0 if the date is before the compared // date. So in this case, if the endDate is before the startDate, then we show // the error. No changes will be made to the model until the error is cleared. if (endDate.compareTo(startDate) < 0) { getEndDateItem().getForm() .setFieldErrors("end_date", "invalid date", true); } else { getEndDateItem().getForm() .clearFieldErrors("end_date", true); } } }); } return theStartDateItem; } /** * This will return an array of SmartGWT TimeUnit options that we want to add to our drop-down * for the Start and End date RelativeDateItem's * * @return array of TimeUnit's */ private TimeUnit[] getTimeOptions() { TimeUnit[] units = new TimeUnit[5]; units[0] = TimeUnit.HOUR; units[1] = TimeUnit.DAY; units[2] = TimeUnit.WEEK; units[3] = TimeUnit.MONTH; units[4] = TimeUnit.YEAR; return units; } /** * This will initialize and construct the end RelativeDateItem * @return Ending RelativeDateItem */ private RelativeDateItem getEndDateItem() { if (theEndDateItem == null) { changeDateFormat(); theEndDateItem = new RelativeDateItem("end_date"); theEndDateItem.setTitle("End:"); theEndDateItem.setOverflow(Overflow.VISIBLE); theEndDateItem.setShowFutureOptions(false); theEndDateItem.setShowPastOptions(true); theEndDateItem.setTimeUnitOptions(getTimeOptions()); theEndDateItem.setDefaultQuantity(1); theEndDateItem.setPresetOptions(theDatePresets); theEndDateItem.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { // Test if this is a relative date selection so we can save it that way RelativeDate relDate = theEndDateItem.getRelativeDate(); Date startDate = (Date)getStartDateItem().getValue(); Date endDate = (Date)theEndDateItem.getValue(); // Per the JavaDoc, compareTo returns less than 0 if the date is before the compared // date. So in this case, if the endDate is before the startDate, then we show // the error. if (endDate.compareTo(startDate) < 0) { theEndDateItem.getForm() .setFieldErrors("end_date", "invalid date", true); } else { // Clear any errors on the field and save the changes to the model theEndDateItem.getForm() .clearFieldErrors("end_date", true); } } }); } return theEndDateItem; } }
Comment
-
Originally posted by Isomorphic View PostThanks, we'll take a look.
Incidentally, it's not clear why you're doing that validation yourself and calling setFieldErrors() via changed handlers - you might want to consider using actual validators and setValidateOnExit(true)
Comment
Comment