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

Learn More

View all

Sign in to view all badges

Add a property to a component's node with Java when dialog is submitted

Avatar

Avatar
Validate 1
Level 1
parag_dalal
Level 1

Likes

2 likes

Total Posts

21 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
parag_dalal
Level 1

Likes

2 likes

Total Posts

21 posts

Correct Reply

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

10-03-2021

Hello guys,

I am stuck on how to achieve a certain result.

 

The end goal is to add a property to a node when the dialog is submitted. The property should ideally be fetched through Java logic and then added to the dialog properties on the generated node. This should happen for a set of components that have a similar resourceType (i.e. they are all in the same folder)

parag_dalal_0-1615364645022.png

 

Essentially I am imagining something like the picture:

1) the dialog contains the editable configurable component's properties

2) on "cq-dialog-submit" if the resourceType startsWith the desired resourceType then

3) pass the info and resource to the Java logic, which fetches the additional property and, once retrieved, adds it to the resource that is the component's node that is going to be generated

4) ultimately the node is generate

5) and the component's node contains all the dialog properties + the additional fetched one.

Above everything else, I am confused on how to activate the Java logic by ensuring that the resource that gets manipulated (by adding an extra property) is exactly the same for which the dialog was submitted; and how to effectively persist the final data/node in the JCR.
So essentially, steps 3 and 4 are the ones that puzzle me the most.

 

For completeness, I would add that this "fetched property" should be added to the node once and for all, but the way I'd handle this is by simply checking if the property is already present when Java receives the order to fetch it, perhaps.

 

Have you guys encountered this need before and have any useful tips, best practices, guidelines to share?

Apologies if I haven't been able to explain myself fully.

 

As always, thank you so much for your contribution,
Parag.

View Entire Topic

Avatar

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

274 likes

Total Posts

320 posts

Correct Reply

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

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

274 likes

Total Posts

320 posts

Correct Reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
Anudeep_Garnepudi
MVP

10-03-2021

@parag_dalal 

What I can think of is, create a servlet which will get content path(/content/..../current-component) as parameter, you can get resourceType from the node. In the servlet you can write the logic. Hit the servlet using Ajax "dialog-success" by passing the path.

Javascript:

  1.  Ajax call to servlet with path in dialog-success event
  2. Can get current component content path from dialog form action attribute

Servlet:

  1. Get the path, get resource using path
  2. Get resourceType
  3. Logic to fetch and set the additional properties/nodes