Hi Guys,
Is it possible to access a page property on a could services configuration page using HTL or do you have to use Java to create an object first?
Cheers Jeff
Solved! Go to Solution.
Views
Replies
Total Likes
Most of the Java-code must indeed placed into a Java-class (WcmUsePojo / Sling Model)
Views
Replies
Total Likes
There is no API that returns cloud information. Also - to configure AEM to use Cloud information, you configure AEM using Cloud Services. See these articles:
Also - watch this Ask the AEM Community Experts:
Views
Replies
Total Likes
Thanks Scott, we are already using AEM cloud services configurations, we are just wanting to redevelop some components that are currently coded using Java scriptlets into HTL components and I was wondering if there was a way to pull the data directly from cloud services.
Views
Replies
Total Likes
What APIs do you use here? Also are you using 6.2 or 6.3?
Views
Replies
Total Likes
Hi Feike,
Using 6.1 but I understand we are upgrading to 6.2 or 6.3 in the near future.
I have found that there was an HTL component that does what we want but the Java tag providing the data needs some updating so hopefully this will be the simplest solution.
Cheers Jeff
Views
Replies
Total Likes
Do you have a more concrete example what you are try to do?
Normally you do a lot with pageProperties or resourcePage.
Views
Replies
Total Likes
Hi Feike,
I am a front end dev and have a few years CQ/AEM experience, I've just started working with 6.1 and am new to HTL.
We are storing API keys as a property on a Cloud Services Configurations pages for a service that we use across multiple websites in our AEM stack, each website has it's own unique key for the service.
We then configure the correct cloud service from each website home page properties we have a JSP component that uses Java Scriptlet code to pull the API key into the site for the service to use.
We would like to change this JSP to an HTL component and as I'm new to HTL I wasn't sure if we could access the cloud services configuration directly in HTL or still needed a Java tag to create the object needed.
Cheers Jeff
Views
Replies
Total Likes
Do have some code that I can look at?
OSGi services can be consumed in HTL, only limitation is that can't invoke methods with parameters.
Views
Replies
Total Likes
Hi Feike,
Here is the contents of the JSP component that we are looking to replace with an HTL component.
Cheers Jeff
<%@page session="false"
import="org.apache.sling.api.resource.Resource,
org.apache.sling.api.resource.ValueMap,
org.apache.sling.api.resource.ResourceUtil,
com.day.cq.wcm.webservicesupport.Configuration,
com.day.cq.wcm.webservicesupport.ConfigurationManager" %><%
%><%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %><%
%><cq:defineObjects/><%
String[] services = pageProperties.getInherited("cq:cloudserviceconfigs", new String[]{});
ConfigurationManager cfgMgr = resource.getResourceResolver().adaptTo(ConfigurationManager.class);
if(cfgMgr != null) {
String api_key = null;
Configuration cfg = cfgMgr.getConfiguration("servicename", services);
if(cfg != null) {
api_key = cfg.get("api_key", null);
}
%>
<!-- API Key -->
<script type="text/javascript">
var apikey = '<%= api_key %>';
</script>
<%
}
%>
Views
Replies
Total Likes
Most of the Java-code must indeed placed into a Java-class (WcmUsePojo / Sling Model)
Views
Replies
Total Likes
Is the Cloud Service Configuration for something that's OOTB (like Analytics etc), or is it a custom API service?
If it's custom, I would suggest moving from Cloud Service Configuration to a more simple OSGI service with a configuration. Doing this would allow you to load the configuration much easier using a WCMUsePojo (or in 6.1, WCMUse) class and give access to the view.
Views
Replies
Total Likes
Just be aware, that you don't need special privileges to create/change Cloud Configuration settings, a regular author (with properly training) can do that. When you store it in an OSGI configuration, it's job for the admin user.
So prefer a CloudConfiguration if an author is supposed to change that.
Views
Replies
Total Likes
Views
Likes
Replies