AEM 6.4 form to store and read from jcr

telpom

21-08-2018

Hi, I'm a new user of AEM.

As an exercise I want to simulate an e-commerce in which I can write and read from jcr ...

In an "insert" page I am using a form container component (start / end) where there are some form text components:

id

brand

model

type

image

and at the end there is send button to refer (after completing all the fields) to the "display" page.

In the "display" page i want to show added products.

I followed these articles

create an AEM project 6.4 Maven archtype 13

https://helpx.adobe.com/experience-manager/using/maven_arch13.html

create a custom action

https://helpx.adobe.com/experience-manager/using/form_component_customaction.html

I have watched default option "store action" how to work, but my problem is how to work its java class to store data. I don't understand it.

I want to store my products in a specific folder, not in a "usergenerated" folder like do "store action".

Alternatively, someone suggest a java script code works effectively to add to jsp file of my custom action.

Thaks to the support

Sorry for my bad english

Accepted Solutions (1)

Accepted Solutions (1)

Ratna_Kumar

MVP

10-09-2018

Hi,

Yes, As Scott stated, you need to follow HELPX article exactly as is and also make sure you create the system user in correct way.

I tested this article Adobe Experience Manager Help | Querying Adobe Experience Manager 6.4 JCR data many times and this works nicely!!

Thanks,

Ratna Kumar.

Answers (8)

Answers (8)

smacdonald2008

22-08-2018

We just updated the article that talks about how to query JCR data. Its important to know how to do this.

Adobe Experience Manager Help | Querying Adobe Experience Manager 6.4 JCR data

This use case will build a HTL component that displays JCR data in a GRID - see this - it shows the HTL component working.

smacdonald2008

10-09-2018

If that article with the video is not working - its most likely because you have not setup the System user properly. You need to follow the article exactly as it and make sure you get the system user created, give correct permissions and use the Sling Mapping Service. Once you do all of this - it works as shown in the video.

telpom

10-09-2018

Finally I have done the insertion page and the visualization page.

In the insertion page I use the action store option and add the directory where to store my products in the edit dialog.

In the visualization page i use HTL commands "data-sly-use" and "data-sly-list" to show the products inserted. In particular with "data-sly-list" to scroll in a dynamic way all the nodes.

My only problem now is to upload images via HTL.

The images of the products that i memorize on the insertion page are of type nt:file (binary format).

Immagine1.png

Immagine2.png

I use the following code to show image but it does not work ...

<sly data-sly-use.product='/etc/Ecom/Products/1535309089485_1/image/jcr:content'>

<img src="${product.jcr:data}">

</sly>

I think the problem is binary format. Are there any solution to resolve the format?

Would you kindly be able to verify that there are no errors or if there is a different way?

telpom

28-08-2018

Thank you, I'm apologize for the late reply.

[1] I have created the Java class in the core package in eclipse, but unfortunately it doesn't work. I think it may be a session problem ...

[2] i have followed it step by step but get employee button is not working.

In alternatively, for the visualization I have created a component where in the html file I insert the following code.

<sly data-sly-use.node = "/ etc / produtcts/product1">

   ${node.jcr:title}

</sly>

Unfortunately it does not work. Do you have any ideas?

telpom

22-08-2018

Hi DarrenBiz,

thank you for answer.

My project is just an exercise on how to write and read into jcr.

I have already done [3] guide, but it didn't work. Probabily different version of aem...

I will try to do [4] guide.

Thanks again

Telpom

DarrenBiz

21-08-2018

If you are using AEM Forms 6.4, my recommendation would be to learn the Forms Data Integration [1] and integrate with a data model via JDBC using a mySQL database [2]. That is fairly easy to set up and is a common pattern you would use with a real instance. Its also very common to offload form data via REST or SOAP but that is usually harder to setup for test purposes. You (should) never use JCR to store data in a real setup for many reasons. The JCR is great but its not recommended to use as a data storage method (mostly due to replication issues).

If you still want to use JCR to persist your form data, there are quite a few tutorials on how to read/write from the JCR in AEM [3] [4]

[1] Adobe Experience Manager Help | AEM Forms Data Integration

[2] Adobe Experience Manager Help | Storing Adaptive Form Data 

[3] Adobe Experience Manager Help | Programmatically Accessing Adobe Experience Manager Content using th...

[4] Scott's Digital Community: Persisting CQ data in the Java Content Repository