Expand my Community achievements bar.

SOLVED

How to store the values entered via component's dialog into repository other than /content/../currentPage/par node

Avatar

Level 2

Hi,

          I have got a requirement where, I need to create a component with dialog, i will add few text fields into it.

          On dialog submit, default behavior : the values entered via dialog will be stored under the current page's jcr:content (or under par node if we use parsys)

          I want the values entered in dialog to be stored under any other path in repository other  /content/../currentPage/par node (may be in /var/audit/ node)

          Is there a way to configure the dialog submit behavior and modify according to my requirements?

    

          for ex : I have a component :  /apps/myProject/components/sample

                       And in component's dialog i have 2 text fields :  cq:dialog->content->layout.....->items->text1 and text2

                      Once i drag-drop this component onto a page and enter vaues to text1 & text2 fields and submit the dialog,

                       The values get stored under : content/somepath/myPage/par/sample -> property_1=text1Value and property_2=text2Value

                         I want there text1Value and text2Value to be stored under some other path in repository.

     Please suggest.

Regards,

Ajay

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

You can make it work as already suggested, but there is a good chance, that this causes problem in the end. Because noone is expecting, that a component dialog is modifying something completely different (potentially even outside of the page). This might also cause problems with permissions (what if the user has write access to the page, but not to the node you want to write to?).

I would strongly suggest to reconsider this approach, and to reflect about and document the impact. What happens when this component is used multiple times inside the page (or on other pages)? Personally I would never allow any dev in my team to implement that, but we would need to find a different, more obvious and understandable solution.

Jörg

View solution in original post

6 Replies

Avatar

Level 3

You should add the name property to field and give its values as path (where you want to store this). This path could be absolute or relative.

Avatar

Level 10

Can you explain why this matters?

AEM Stores and retrieves the values from the JCR and to an author - the values appear when the dialog is opened. What is the benefit of changing the JCR location that a component dialog uses?

Avatar

Correct answer by
Employee Advisor

You can make it work as already suggested, but there is a good chance, that this causes problem in the end. Because noone is expecting, that a component dialog is modifying something completely different (potentially even outside of the page). This might also cause problems with permissions (what if the user has write access to the page, but not to the node you want to write to?).

I would strongly suggest to reconsider this approach, and to reflect about and document the impact. What happens when this component is used multiple times inside the page (or on other pages)? Personally I would never allow any dev in my team to implement that, but we would need to find a different, more obvious and understandable solution.

Jörg

Avatar

Level 2

I tried adding name property to field and gave its values as : /var/audit/test (i tried ./var/audit/test  also)

    

     But i see my textfield value stored under :  /content/...../currentPage/par/var/audit/test

     While i was expecting it to be stored under /var/audit/test node.

Avatar

Level 3

You have started the path with ./ which denotes the current page path.

For absolute path (for eg. /var/audit/test) enter the value without '.'

Avatar

Level 3

Couldn't agree with this more.  Sounds like you need to revisit the implementation.