defaultValue property removed in coral numberfield in AEM 6.4? | Adobe Higher Education
Skip to main content
Level 2
January 10, 2019
Répondu

defaultValue property removed in coral numberfield in AEM 6.4?

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!!

Ce sujet a été fermé aux réponses.
Meilleure réponse par Rohit-Negi

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.

9 commentaires

smacdonald2008
Level 10
January 10, 2019

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

arunpatidar
Community Advisor
Community Advisor
January 10, 2019

Hi

Use "value" property insteadof "defaultValue" .

Arun Patidar
smacdonald2008
Level 10
January 10, 2019

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

Level 2
January 11, 2019

Hi Arun Patidar​,

I have tried your approach.

And there is one issue related to value property.

I gave value for coral numberfield.

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

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:

Removed the authored value and opened the dialog again :

The value is not displaying.

Any help on this?

January 18, 2021

This happens because, as @arunpatidar 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
January 11, 2019

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

arunpatidar
Community Advisor
Community Advisor
January 11, 2019

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.

Arun Patidar
Rohit-Negi
Rohit-NegiRéponse
Level 3
January 14, 2019

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.

Level 2
January 16, 2019

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.

BrianKasingli
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
September 7, 2022

@sundarig9086821,

 

Today, I struggled to set a default value for the numberfield.

 

I followed @rohit-negi's solution, but there was a problem. Setting the value property for the numberfield only works when new components are authored by the content authors, but existing component when configured, fail to pick up the default value.

I have spent some time in my evening coming up with a custom solution to solve this. Take a look here -> https://sourcedcode.com/blog/aem/aem-granite-ui-coral-3-number-field-default-value