Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

AEM 6.1 Touch UI: Datepicker Field not prepopulated with stored value

Avatar

Former Community Member

Hi!

 

I'm currently facing a strange issue:

I've a component that includes text inputs and a date picker (Resource Type: granite/ui/components/foundation/form/datepicker).

I can add and edit values for all input fields and they are shown properly on the component on the edited webpage.

The system also stores all values properly.

 

But when I re-open the dialog the value for the date selected via date picker is not shown. The date picker input field remains empty.

All other inputs are prepopulated with the stored values.

The date is shown on the component but not in the date picker.

If I save the dialog with the empty date picker value the date will be overwritten with null.

 

Any idea what I can do to show the entered date there?

 

Thanks and best regards

Sebastian

1 Accepted Solution

Avatar

Correct answer by
Level 2

Ah ok, you are using type="date" (the first property of your datepicker) this is what i meant.

I see your problem, you are using just type=date but by default this is storing in date-time format and thats why the dialog is not able to display the value.

2 Solutions-

1. If you want to retain type="date", have the additional property storedValue something like storedValue="YYYY-MM-DD" make sure you are not specifying time

2. change type="datetime", you don't need to specify the storedValue property in this case, and this lets you specify the time too.

Observe the content node for the stored value. You can use the properties accordingly for display purpose.

View solution in original post

8 Replies

Avatar

Level 2

Hi Sebastian,

Have you specified the displayedFormat property?

Like: displayedFormat=YYYY-MM-DD

Which type are you using date, datetime, time,...?

Avatar

Former Community Member

Hi Vinay,

 

these are the properties of the datepicker:

type=date (string)

displayedFormat=YYYY-MM-DD (string)

jcr:primaryType=nt:unstructured (name)

name=./jcr:startdate (string)

sling:resourceType=granite/ui/components/foundation/form/datepicker (string)

fieldLabel=Start Date (string)

fieldDescription=Enter Start Date (string)

 

I'm using "java.util.Date startdate = properties.get("jcr:startdate", java.util.Date.class);" to get the input and use it in my JSP component file.

This is an example output of the startdate value without any formatting: Tue Mar 28 00:00:00 CEST 2017

 

I don't see any further information about the date type itself whether it's date, datetime or time.

 

Thanks

Sebastian

Avatar

Correct answer by
Level 2

Ah ok, you are using type="date" (the first property of your datepicker) this is what i meant.

I see your problem, you are using just type=date but by default this is storing in date-time format and thats why the dialog is not able to display the value.

2 Solutions-

1. If you want to retain type="date", have the additional property storedValue something like storedValue="YYYY-MM-DD" make sure you are not specifying time

2. change type="datetime", you don't need to specify the storedValue property in this case, and this lets you specify the time too.

Observe the content node for the stored value. You can use the properties accordingly for display purpose.

Avatar

Former Community Member

Thanks-a-lot for your help, Vinay. Problem solved.

Avatar

Level 2

Hi REES,

I am having the same issue with the datepicker.  Below is how the datepicker is configured. I tried using type="date" but still no use. It works if i use type="datetime" but i want to use date only so can you please provide some information on how you were able to solve the issue?

<articleDate   fieldLabel="Date"   name="./articleDate"   sling:resourceType="granite/ui/components/foundation/form/datepicker"   displayedFormat="MMM-DD-YYYY"   valueFormat="YYYY-MM-DD"   storedValue="YYYY-MM-DD"   jcr:primaryType="nt:unstructured"/>

Avatar

Level 2

It was a bug, which has been fixed in CFP7.

NPR-15384: HotFix for GRANITE-16481

Here is the link. Adobe Experience Manager Help | Release Notes: AEM 6.1 Cumulative Fix Pack

The issue is only in chrome browser.

Thanks,

Thilak

Avatar

Level 3

how can we get the value in htl ?

${properties.articleDate} does not work . I would need time and date .

i don't want to create a java class to read this datetime node . Is there any other way in 6.1 ?

Avatar

Level 2

try this:

${properties.articleDate.getTime.toString}