April 13, 2020
Estimated Post Reading Time ~

Using JSONWriter objects to display Adobe CQ OSGi data

You can create an org.apache.sling.commons.json.io.JSONWriter instance to invoke Adobe CQ OSGi bundle operations and display data within a JSP. A JSONWriter instance lets you define value and key methods to retrieve data. You can create an Adobe CQ component that uses a JSONWriter instance to submit data to an OSGi bundle operation and get back the results. You can then display the results in a JSP. That is, you can dynamically display data based on user input.

For example, consider the OSGi bundle that uses web services to return weather information. (For information about this OSGi bundle, see 
https://aem4beginner.blogspot.com/2020/04/creating-adobe-cq-bundles-that-consume.html
)

Note The OSGi bundle that returns weather data uses web services to expose various operations that return weather data. To follow along with this development article, you must create the weather OSGi bundle by following that article.

You can use a JSONWriter instance to return weather data based on user input. For example, consider the following graphical user interface that lets a user select a US ZIP code from a drop-down menu:


When the user selects a US Zipcode from the drop-down menu and clicks the Click Me button, the weather service OSGi bundle is invoked. A JSONWriter instance is used to invoke the OSGi bundle and the data is returned to the JSP, as shown in the following illustration.


To read this full article, click this link:
http://helpx.adobe.com/experience-manager/using/using-jsonwriter-objects-display-cq.html


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.