which would be a better option

Avatar

Avatar
Validate 1
Level 1
AEMnewbie
Level 1

Likes

0 likes

Total Posts

86 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
AEMnewbie
Level 1

Likes

0 likes

Total Posts

86 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile
AEMnewbie
Level 1

08-01-2021

I am trying to use some validation on a field which save a dialog box or i could also set a property while creating a page and remove that field from dialog box. which one is a preferred option .

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

644 likes

Total Posts

606 posts

Correct reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

644 likes

Total Posts

606 posts

Correct reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
BrianKasingli
MVP

08-01-2021

@AEMnewbie,

There are 2 tactics that I see that are common while validating Touch UI dialogues in AEM; a front-end way and a back-end way. I prefer the front-end way, as logic in the front-end will highlight the input field that is not valid, and also not allow the content authors to save the dialogue. 

Out of the box, AEM Granite UI (Touch UI)Dialogues are using the jQuery Validation plugin. You can create your own jQuery Validation.

Take a look at this tutorial, where it shows you how to implement your own jQuery Validation for adding AEM RichText Max Characters Length Validation - https://sourcedcode.com/blog/aem/touch-ui/aem-richtext-max-characters-length-validation

The back-end way will be you allowing the authors to save whatever value they choose, and the component in the editor mode page will display the component in RED (or some other indication) that there's a problem with the form dialogues. Sometimes you need to do this because you may want to validate the form data with your AEM backend... but you will be definitely introducing validation variables and code in your AEM component's sling model. 

As you can imagine, the front-end way of using jQuery Validation gives the author a much quicker and instant feedback on what is missing In the touch UI dialogue.

 

Answers (4)

Answers (4)

Avatar

Avatar
Boost 100
Level 6
snbaem
Level 6

Likes

112 likes

Total Posts

245 posts

Correct reply

35 solutions
Top badges earned
Boost 100
Springboard
Establish
Validate 25
Validate 10
View profile

Avatar
Boost 100
Level 6
snbaem
Level 6

Likes

112 likes

Total Posts

245 posts

Correct reply

35 solutions
Top badges earned
Boost 100
Springboard
Establish
Validate 25
Validate 10
View profile
snbaem
Level 6

08-01-2021

Hi,

 

You  can choose based on use case. If the property is something that is must have for most pages, you can have it available during page creation (and as required probably) so that its value is set when a page is created. The authors don't need to worry about opening  dialog again. The equivalent to dialog submit validation might have to be found.

If the property is an optional one, and needs to reside in a component dialog it can be chosen too, but its an add extra step for authors.

Avatar

Avatar
Ignite 1
MVP
Ankur_Khare
MVP

Likes

159 likes

Total Posts

370 posts

Correct reply

58 solutions
Top badges earned
Ignite 1
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile

Avatar
Ignite 1
MVP
Ankur_Khare
MVP

Likes

159 likes

Total Posts

370 posts

Correct reply

58 solutions
Top badges earned
Ignite 1
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile
Ankur_Khare
MVP

08-01-2021

Better do it at dialog level.

Avatar

Avatar
Springboard
MVP
Shashi_Mulugu
MVP

Likes

232 likes

Total Posts

294 posts

Correct reply

67 solutions
Top badges earned
Springboard
Bedrock
Validate 1
Applaud 100
Establish
View profile

Avatar
Springboard
MVP
Shashi_Mulugu
MVP

Likes

232 likes

Total Posts

294 posts

Correct reply

67 solutions
Top badges earned
Springboard
Bedrock
Validate 1
Applaud 100
Establish
View profile
Shashi_Mulugu
MVP

08-01-2021

It depends on the type of field ands it's usecase.  If you can set the field value while creating the page automatically then why to make author enter its value in dialog and add validation?

 

If it has to be controlled by author make it as a field in dialog, if it a backend driven value which is not author friendly then make it automatic.

 

Hope this helps.

Avatar

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

192 likes

Total Posts

243 posts

Correct reply

75 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

192 likes

Total Posts

243 posts

Correct reply

75 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile
Ravi_Pampana
MVP

08-01-2021

Hi,

 

If you are adding a field in dialog where authors enters, it is good to validate on dialog submit instead of page