1
votes

At my new job I'm forced to use Adobe AEM and everything that comes with it. But because everything is new to me and to my team, we are having some major dificulties understanding what are the best practices and what's the correct "code workflow". I've read everything that I could, but something's messing with my head and I just can't figure it out alone.

My question is: When I don't want to work with the JCR tree, and I just want to make a component for a specific user (not a real CMS component, I guess), I can't understand how I'm able to reload my component information (based on some Model).

So... imagine I have an authenticated user that has N Cars. And I've developed a component that shows the information of one of those Cars. The selected Car can change and I want to update the component with the selected Car information.

By default, when the page loads, the Car number 1 is loaded.

First question: How should this first Car be loaded? My first try on this one was to backup my component with a WCMUse extension, and on the activate() method I would set my default Car properties.

But this seems odd to me, because I don't know how I connect this class to my Spring Controller...

I've read that ResourceModel can be used for this, but that it would map its properties to a Car JCR node that I don't have.

Second Question: Imagine that the first Car is correctly loaded and I call a method on my Spring Controller to update it. What needs to be done to reflect this change on the Car information component?

So, to finish, I guess my main 2 problems are: What should be the model for the Sightly component, and how does the component refresh with the updated information.

Thanks a lot.

1

1 Answers

0
votes

Welcome to AEM world silva, sad to listen that you are forced to work in AEM.

Though it might appear difficult initially , a developer worth his salt can gain enough expertise to work with AEM in around 6 months. For a Java developer it is difficult to relate things.

Coming back to your problem: If I understood you well you don't want to store you data in JCR and you want to hit your Spring controller to fetch the data.

Answer to First question: Ideally in AEM the data resides in JCR, it may be a User node and then Car0,Car1... CarN child nodes, here all car details are stored on car node as properties. It is all about how you want to structure your content.

If you plan not to store data in JCR you can create a OSGI service which can get the data from your spring controller and pass on to the sightly component.

Answer to Second question you can pass a parameter to your sightly component and get the relevant view of carN, Checkout Passing parameters to sightly .

You also can create href's which will load the same page and pass on some request parameter which you can read in your WCMUse (WCMUsePojo in AEM 6.2) extension activate method.

Keep learning keep helping, Cheers!