Remove time selection in oxy_datePicker

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
vitorhugovm
Posts: 31
Joined: Fri Jan 26, 2024 3:31 pm

Remove time selection in oxy_datePicker

Post by vitorhugovm »

Hello!

I'm in need of using oxy_datePicker to allow date selection inside a node. I need to allow selection only for the date so I can intercept the inserted text and add the current time and timezone.
I tried to use the "format" property with "yyyy-MM-dd", but it keeps showing the time selection. I read that it is supposed to work only when a format is not detected in the associated document schema. Is there a way I can surpass the schema format in this case or force the time selection to not appear?

Thanks!
Vitor
cristi_talau
Posts: 513
Joined: Thu Sep 04, 2014 4:22 pm

Re: Remove time selection in oxy_datePicker

Post by cristi_talau »

Hello,
One way to avoid datePicker use the format from the schema, is to use a SchemaManagerFilter and override the getAttributeDescription method [1] to return no format. Then, to intercept the setting of the form-control you can use an AuthorDocumentFilter [2].
Another option is to implement a custom form control [3] and implement the entire behavior yourself.

Best,
Cristian

[1] https://www.oxygenxml.com/InstData/Edit ... teContext)
[2] https://www.oxygenxml.com/InstData/Edit ... ilter.html
[3] https://www.oxygenxml.com/maven/com/oxy ... ntrol.html
vitorhugovm
Posts: 31
Joined: Fri Jan 26, 2024 3:31 pm

Re: Remove time selection in oxy_datePicker

Post by vitorhugovm »

Hello Cristian!

Instead of overriding getAttributeDescription method, I overwritten the getElementDescription method, because I'm editing the text inside the node and not an attribute. In the schema the element has the type xs:dateTime.
I tried to use setTypeDescription inside the new method, but it didn't change the behavior.

I have another question. Is there a way to call the oxy_datePicker component inside JavaScript or Java?

Thanks!
Vitor
cristi_talau
Posts: 513
Joined: Thu Sep 04, 2014 4:22 pm

Re: Remove time selection in oxy_datePicker

Post by cristi_talau »

Hello,

You should try to call setModelDescription to make simulate that the date has no specified format in the schema.
Regarding your second question, there is no way to reuse the code of the builtin date picker if you implement your own. On the other hand, the builtin date picker just uses the browser's <input type="date"> element.

Best,
Cristian
Post Reply