Timezone offset issue for date field in hidden datasource list

Hello,

You fixed a bug in your 5.5.1 or 5.6 release related to timezone offsets. If a client browser was in a different timezone from the server, date fields were displaying incorrectly in the browser. Your fix handles the date rendering for all fields of type date. However, we are having this issue for a hidden list that is part of a datasource. And, that hidden list contains a date field. Is there anything we can do to utilize the same fix you applied for date fields to this field on our hidden list?

Hi senordhuff,

What do you mean by a hidden list? What’s the DataSource declaration look like? How is the data edited and saved and how are timezone issues manifesting for you?

Hi, I mean that I have a field on my “FundAsset” datasource that looks like this:

<field name=“assetScenarioList” hidden=“true” />

That field is populated server side with an ArrayList. The ArrayList contains a list of objects that includes a date field. So, when I call FundAsset.fetchData(), it fetches a list of FundAsset records. And, each FundAsset record has an assetScenarioList.

On the Client side, the date field in “assetScenarioList” is displaying with this timezone offset issue. We display assetScenarioList in the row hover text for a grid using “FundAsset” as the Datasource.

So, if the date on the server is “12/6/07 00:00:00 EST” then a browser with it’s timezone set to EST will display it as “12/6/07” but a browser with it’s timezone set to PST will display the date as “12/5/07”. You included a fix in 5.6 or 5.5.1 to resolve this issue for any field declared in a datasource as type=“date”. However, in this case, the date field is part of a hidden list of “assetScenarioList” so it is not defined as a date.

Let me know if that explains it well enough. I think, but I’m not sure, that the fix for “date” fields is related to this patch: http://forums.smartclient.com/showthread.php?t=421&highlight=timezone

Hi Dave,

Your best approach may be to declare those hidden dates in the DataSource but mark it hidden:true so that it does not appear in the UI. This will cause SmartClient’s date handling to kick in.

What you are seeing right now isn’t due to SmartClient, it’s simply that dates stored in one timezone and rendered in another (as Date.toString() does by default) don’t match.

Hi, I do understand this isn’t a SmartClient issue. But, I’m trying to apply the fix you automatically apply to fields of type date to my field that isn’t defined as part of the datasource. And, I’m not really sure how I could define it as part of the datasource because it is a field on “assetScenarioList” and not on the DataSource.

For instance, this is how I typically access the date when working with a ListGridRecord from this Datasource:

 for(var i=0;i < record.assetScenarioList.length;i++){
         var scenario = record.assetScenarioList[i];
         var occurenceDate = scenario.occurenceDate;
}

So, any ideas how could I declare occurenceDate in the above example as part of the datasource to resolve this timezone issue? Or, is their a way to apply the same fix without declaring it as a date on the Datasource which may not be possible?

See fieldType - you can actually declare a field to be of DataSource type. In this case, since "assetScenarioList’ is actually a list of objects, you would also set multiple:true.

That seems encouraging. I didn’t realize you could define a field as a Datasource because I set all of this up back in 5.5 and I guess this wasn’t possible (or at least documented) back then. So, hopefully we are on the right track. But, unfortunately, making that change doesn’t resolve the issue.

I updated my field declaration as follows:

<field name=“assetScenarioList” type=“AssetScenario” multiple=“true” hidden=“true” />

And, AssetScenario is a Datasource like this (it includes some other fields as well left off for brevity):

<DataSource xmlns:spring="urn:jsptld:/WEB-INF/spring.tld" ID="AssetScenario" >

<field name="occurenceDate" type="date"   >
	<title>
	<spring:message code="label.as.date"/>
	</title>
</field>

</Datasource>

So, any ideas why I would still be having the timezone offset issue? Do I possibly need to access the field differently client-side than what you see below to trigger SmartClient’s automatic handling of timezone offsets?

 for(var i=0;i < record.assetScenarioList.length;i++){
         var scenario = record.assetScenarioList[i];
         var occurenceDate = scenario.occurenceDate;
}

Hi senordhuff,

Your field declaration is correct, however, you are correct that it will not actually cause automatic date handling to kick on.

However you should be able to wrap your List of AssetScenario objects explicitly in a JSONFilter before passing the overall structure to setData().

Ok, I’m having a little trouble understanding exactly how the JSONFilter is supposed to work. This is what my code looks like server-side to add an “AssetScenarioList” to each “FundAsset” record currently…

//inside a loop to populate FundAsset records with a List called assetScenarioList on each FundAsset?
FundAssetRecord
fundAssetDTO.setAssetScenarioList(this.getAssetScenarioDTOList());

Above, this.getAssetScenarioDTOList() obviously returns a List. Are you saying I’ll need to rework this API to accept a string instead so I can use a JSONFilter each time I call setAssetScenarioList for each FundAsset record?

So, should it look like this?

//inside a loop to populate FundAsset records that puts a JSON filtered string representing assetScenarioList on each FundAsset?
try{
   String scenarioListString = JSTranslater.get().toJS(new JSONFilter(this.getAssetScenarioDTOList(),"AssetScenario",false));
   //this would be a new method to set a string representing the list on each FundAsset record
   fundAssetDTO.setAssetScenarioListString(scenarioListString);
}catch(UnconvertableException e){
			
}

Or, do I apply this JSONFilter somehow to the entire list of “FundAsset” records immediately before calling setData?

You don’t need to use the JSTranslater directly. The simplest thing is to create an API that returns a JSONFilter wrapping the assetScenarioList, for example, "JSONFilter getAssetScenarioListJSON() { … "

If you then create a field in the DataSource assetScenarioListJSON, getAssetScenarioListJSON() will be called and the resulting data will be translated with awareness of the DataSource schema, so that Date fields are treated specially.

Thank you, works great.

“We have this mission to a tool that give every business, large or small, intelligent lead-generation tool that (Buy WOW Gold) includes all the holes would build,” said Burst. What burst and its partners Dukky is designed simply (WOW Power Leveling) a souped-lead-generation device. It makes print advertising traceable, and it allows marketers to see the progress of their campaigns in real time. He is building a deep database - the all-important fast WOW Gold list - as it goes along. And as social media - give the respondents the opportunity to promote on Facebook, Twitter, or another outlet to share - it can be the (Aion Leveling)despised coupon-in-the-mailbox a full-on, viral marketing phenomenon.