Expand my Community achievements bar.

Creating an AEM HTML Template Language Component that displays data from a Restful Web Service

Avatar

Level 10

You can create an Adobe Experience Manager (AEM) HTML Template Language (HTL)   component that displays data retrieved from a third-party Restful web service. For example, assume you want to display data based on the distance between two cities on your web site. In this situation, you can develop an AEM HTL component that displays data between two cities, as shown in this illustration.

 

In this use case, the HTL component contains a class that extends WCMUsePojo. This class uses Java application logic to send a HTTP Request to a third-party Restful web service. The web service returns the following data in JSON format. 

 {  
   "destination_addresses":[  
      "Dallas, TX, USA"
   ],
   "origin_addresses":[  
      "Ottawa, ON, Canada"
   ],
   "rows":[  
      {  
         "elements":[  
            {  
               "distance":{  
                  "text":"2,714 km",
                  "value":2713758
               },
               "duration":{  
                  "text":"1 day 1 hour",
                  "value":89044
               },
               "status":"OK"
            }
         ]
      }
   ],
   "status":"OK"
}

The HTL component uses the Java library GSON to parse the JSON data and then displays the data in the client so it appears in the AEM web page. To read this development article, click https://helpx.adobe.com/experience-manager/using/restful_htl.html

1 Reply

Avatar

Level 2

I"m trying to get this to work in AEM 6.3 but the form fields aren't showing in the dialog during the test. Anyone done this in 6.3?