Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

defaultValue property removed in coral numberfield in AEM 6.4?

sundarig9086821
Level 3
Level 3

Hi,

We are facing issue in making numberfield change from granite/ui/components/foundation/form/numberfield to granite/ui/components/coral/foundation/form/numberfield in AEM6.4.

As per this document, NumberField — Granite UI 1.0 documentation  the defaultValue property has been removed for 6.4

However the property exists for 6.3 -- NumberField — Granite UI 1.0 documentation 

How can we achieve Coral numberfiled along with defaultProperty in AEM 6.4?

smacdonald2008Arun Patidar​ any help on this?

Thanks in advance!!

1 Accepted Solution
Rohit_Negi550
Correct answer by
Level 4
Level 4

HI @sundarig90868210

You can achieve the same by using @DefualtValue.

Try the below:-

<number

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="granite/ui/components/coral/foundation/form/numberfield"

                        fieldDescription="Value of Product"

                        fieldLabel="Page value"

                        name="./testValue"/>

<number-default

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="/libs/granite/ui/components/coral/foundation/form/hidden"

                        name="./testValue@DefaultValue"

                        value="{Long}11"/>

Make sure name property remain the same with @DefaultValue appended in the hidden one.

View solution in original post

9 Replies
smacdonald2008
Level 10
Level 10

I am checking with the Touch UI team to see what is happening here.

Arun_Patidar
Community Advisor
Community Advisor

Hi

Use "value" property insteadof "defaultValue" .

smacdonald2008
Level 10
Level 10

Nice suggestion - I am going to test this later today.

sundarig9086821
Level 3
Level 3

Hi Arun Patidar​,

I have tried your approach.

And there is one issue related to value property.

I gave value for coral numberfield.

1665008_pastedImage_0.png

After when i use this component in page, in dialog i am able to see the value initially.

1665009_pastedImage_1.png

After that i have authored with some value and saved it. If i open the dialog again and removed the authored value and save it again the value(which is supposed to be displayed) is not appearing in dialog.

Authored value:

1665010_pastedImage_2.png

Removed the authored value and opened the dialog again :

1665011_pastedImage_3.png

The value is not displaying.

Any help on this?

gael_quintillan
Level 1
Level 1

This happens because, as @Arun_Patidar said, the "value" property depends on jcr:created and jcr:lastModified, if they are different it means that the crx node was modified and therefore the crx value is shown (and "value" property is not used). The same happens when the properties jcr:created and jcr:lastModified are not present.

smacdonald2008
Level 10
Level 10

that is because you removed the value. If you remove the value - it's gone.

Arun_Patidar
Community Advisor
Community Advisor

Hi,

The value property values only persist if jcr:created and jcr:lastModified date is same for a component node in content.

That means once component is authored, the dialog values will be fetched from save properties.

If you always need value property in case of empty you can add data attribute using granite:data node and set any property with default value and with the help of javascript on dialog load you can check if number filed is empty you can fill it from data attribute value.

Rohit_Negi550
Correct answer by
Level 4
Level 4

HI @sundarig90868210

You can achieve the same by using @DefualtValue.

Try the below:-

<number

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="granite/ui/components/coral/foundation/form/numberfield"

                        fieldDescription="Value of Product"

                        fieldLabel="Page value"

                        name="./testValue"/>

<number-default

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="/libs/granite/ui/components/coral/foundation/form/hidden"

                        name="./testValue@DefaultValue"

                        value="{Long}11"/>

Make sure name property remain the same with @DefaultValue appended in the hidden one.

View solution in original post

sundarig9086821
Level 3
Level 3

Hi NegiCF​,

Thanks fo the solution. It worked.

Is this the proper way of defining defaultvalue in numberfield from 6.4 or is there any other reason for removal of delaultValue property from coral-numberfield?

Thanks,
Sundari.