Question Marcus Bondezan · May 4, 2018

Zen - Problem with dateText component (format and separator attributes)


When working with the dateText component in a Zen Application and setting the parameters "format:DMY" and "separtator:/" I cannot save the  right date to the database.

In short, I have a structure similar to :

Class View.A Extends  %ZEN.Component.page{XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{... <dataController id="a-controller" modelClass="MVC.A"/> <dynaForm id="a-form"  controllerId="a-controller" onsubmit="return zenPage.saveForm();"/>}}
Class MVC.A Extends %ZEN.DataModel.ObjectDataModel{Property DOB As %Date  (ZENATTRS = "id:DOB|format:DMY|separator:/, ZENCONTROL = "dateText") ;... other methodsMethod %OnStoreModel(pSource As Modelo.Pedido) As %Status
{
  Set pSource.DOB = ..DOB
  Quit $$$OK
}}
Class Model.A Extends %Persistent{Property DOB As %Date;}

When I don't use the attributes "format" and "separator", then it's saved normally. However, with them , the date saved is  "1840-12-31".

I've seen the below post about a similar subject, but it was a long time ago. Is it possible that the bug still exists in version "2015.2.1.705.1" (mine)?

https://groups.google.com/forum/#!topic/intersystems-zen/VLCqAlXumjI

I wonder if someone could point the solution to me.

Comments

Vitaliy Serdtsev · May 7, 2018
USER>w $zv
Cache for Windows (x86-32) 2015.2 (Build 664_3U) Wed Aug 12 2015 12:29:34 EDT
The date is saved to the database correctly.
Class dc.A Extends %Persistent

</FONT><FONT COLOR="#000000">{ </FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">DOB </FONT><FONT COLOR="#000080">As %Date</FONT><FONT COLOR="#000000">; }</FONT>

<FONT COLOR="#000080">Class dc.MVC.A Extends %ZEN.DataModel.ObjectDataModel </FONT><FONT COLOR="#000000">{

</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">DOB </FONT><FONT COLOR="#000080">As %Date</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">ZENATTRS </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"id:DOB|format:DMY|separator:/"</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">ZENCONTROL </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"dateText"</FONT><FONT COLOR="#000000">);

</FONT><FONT COLOR="#000080">Method </FONT><FONT COLOR="#000000">%OnNewSource(</FONT><FONT COLOR="#000080">Output </FONT><FONT COLOR="#ff00ff">pSC </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">= {</FONT><FONT COLOR="#0000ff">$$$OK</FONT><FONT COLOR="#000000">}) </FONT><FONT COLOR="#000080">As %RegisteredObject </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">dc.A</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">() }

</FONT><FONT COLOR="#000080">Method </FONT><FONT COLOR="#000000">%OnOpenSource(   </FONT><FONT COLOR="#ff00ff">pID </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">,   </FONT><FONT COLOR="#ff00ff">pConcurrency </FONT><FONT COLOR="#000080">As %Integer </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#000080">-1</FONT><FONT COLOR="#000000">,   </FONT><FONT COLOR="#000080">Output </FONT><FONT COLOR="#ff00ff">pSC </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">= {</FONT><FONT COLOR="#0000ff">$$$OK</FONT><FONT COLOR="#000000">}) </FONT><FONT COLOR="#000080">As %RegisteredObject </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">dc.A</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%OpenId</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">pID</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">pConcurrency</FONT><FONT COLOR="#000000">,.</FONT><FONT COLOR="#800000">pSC</FONT><FONT COLOR="#000000">) }

</FONT><FONT COLOR="#000080">Method </FONT><FONT COLOR="#000000">%OnSaveSource(</FONT><FONT COLOR="#ff00ff">pSource </FONT><FONT COLOR="#000080">As dc.A</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#800000">pSource</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%Save</FONT><FONT COLOR="#000000">() }

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">%OnDeleteSource(</FONT><FONT COLOR="#ff00ff">pID </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">dc.A</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%DeleteId</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">pID</FONT><FONT COLOR="#000000">) }

</FONT><FONT COLOR="#000080">Method </FONT><FONT COLOR="#000000">%OnLoadModel(</FONT><FONT COLOR="#ff00ff">pSource </FONT><FONT COLOR="#000080">As dc.A</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">DOB </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800000">pSource</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DOB   q $$$OK </FONT><FONT COLOR="#000000">}

</FONT><FONT COLOR="#000080">Method </FONT><FONT COLOR="#000000">%OnStoreModel(</FONT><FONT COLOR="#ff00ff">pSource </FONT><FONT COLOR="#000080">As dc.A</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">pSource</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DOB </FONT><FONT COLOR="#000000">= ..</FONT><FONT COLOR="#0000ff">DOB   q $$$OK </FONT><FONT COLOR="#000000">}

}</FONT>

<FONT COLOR="#000080">Class dc.test Extends %ZEN.Component.page </FONT><FONT COLOR="#000000">{

</FONT><FONT COLOR="#000080">XData </FONT><FONT COLOR="#000000">Contents [ </FONT><FONT COLOR="#000080">XMLNamespace </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"http://www.intersystems.com/zen" </FONT><FONT COLOR="#000000">] {   <</FONT><FONT COLOR="#000080">page </FONT><FONT COLOR="#800000">xmlns</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"http://www.intersystems.com/zen"</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">dataController </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"a-controller" </FONT><FONT COLOR="#800000">modelClass</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"dc.MVC.A" </FONT><FONT COLOR="#800000">modelId</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">""</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">dynaForm </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"a-form"  </FONT><FONT COLOR="#800000">controllerId</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"a-controller"</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">button </FONT><FONT COLOR="#800000">caption</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Save" </FONT><FONT COLOR="#800000">onclick</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"zen('a-form').save();" </FONT><FONT COLOR="#000000">/>   </</FONT><FONT COLOR="#000080">page</FONT><FONT COLOR="#000000">> }

}</FONT>

0
Marcus Bondezan  May 21, 2018 to Vitaliy Serdtsev

Thank you for the rapid response Vitaliy Serdtsev .

I'm new to Caché and I was probably doing something wrong when manipulating the data in the %OnStoreModel method.  I've started it fresh again and now it's working as expected.

0