Solved! Go to Solution.
Views
Replies
Total Likes
See the community article that gets at the local JCR from a component.
http://helpx.adobe.com/experience-manager/using/creating-custom-cq-tree.html
It populates the front end component with data from the JCR.
Also - from an OSGi component (or JSP) never use:
//Create a connection to the Adobe Day CQ repository running on local host
Repository repository = JcrUtils.getRepository("http://localhost:4502/crx/server");
This code is used when you want to get at the JCR from an external Java app - like a console app or a Swing app. For details about how to write a Java Swing app that that pull up data from an AEM JCR -- see:
http://helpx.adobe.com/experience-manager/using/java-swing-applications.html
To properly get at the JCR from within an OSGi component - use:
resourceResolver.adaptTo(Session.class);
To learn how to write an OSGi component that uses this code to retrieve JCR Data:
http://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html
Views
Replies
Total Likes
Hi Clive,
If your need is to only list down the select options dynamically then you can also drive it from servlet of JSP file.
refer to foundations, list component - /libs/foundation/components/list/dialog/items/list/items/displayAs to know how you can do it.
Also can you put down the details why you are trying to get repository reference? if you simply want to drive drop down options from somewhere else in repository like etc/dropdownnodes/node1 etc.. then you can directly get the parent node reference using Resourceresolver and if you are to consider permissions before getting the nodes options then as Fieke suggested don't use admin session, rather use logged-in user session.
- Runal
Views
Replies
Total Likes
Use the below code to create session
ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null); Session session = resourceResolver.adaptTo(Session.class);
Views
Replies
Total Likes
See the community article that gets at the local JCR from a component.
http://helpx.adobe.com/experience-manager/using/creating-custom-cq-tree.html
It populates the front end component with data from the JCR.
Also - from an OSGi component (or JSP) never use:
//Create a connection to the Adobe Day CQ repository running on local host
Repository repository = JcrUtils.getRepository("http://localhost:4502/crx/server");
This code is used when you want to get at the JCR from an external Java app - like a console app or a Swing app. For details about how to write a Java Swing app that that pull up data from an AEM JCR -- see:
http://helpx.adobe.com/experience-manager/using/java-swing-applications.html
To properly get at the JCR from within an OSGi component - use:
resourceResolver.adaptTo(Session.class);
To learn how to write an OSGi component that uses this code to retrieve JCR Data:
http://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html
Views
Replies
Total Likes
hi clive,
The code that you have is used to connect to another/external JcrRepository.
From your JSP/component you can do this:
resource.getResourceResolver().adaptTo(Session.class)
This then uses the session of the current user (and his permissions).
And yes you can also use the 'admin resource-resolver', but try to avoid that unless there is a real need for it.
--
feike
Views
Replies
Total Likes
Views
Likes
Replies