Expand my Community achievements bar.

Porperties Fecthing Using Listeners

Avatar

Former Community Member

I want to fetch the name property i,e ("/.name") in my Listeners without using dialog.getField('./name').getValue(); any Solutions.

2 Replies

Avatar

Administrator

Hi 

Please refer to this community article:- 

Link:- http://aem.matelli.org/fetching-properties-from-dialogs/

// This overs many options for Fetching Properties From Dialogs


Op1:- Sling’s RESTful model, we can view that property directly in a browser by visiting the path listed above.

Link:- http://localhost:4502/apps/geometrixx-outdoors/components/page/jcr:title

Op2:- <%
    String title = properties.get("jcr:title", "default title");
    String text = properties.get("jcr:text", "default text");
    //String title = properties.get("jcr:title", String.class); //defaults to null
%>

Op3:-

Node node = myResource.adaptTo(Node.class);
title = node.getProperty("jcr:title").getString();
text= node.getProperty("jcr:text").getString();

Op4:- 

Page myPage = currentPage; //reference to whatever page contains the component";
String componentPath = myPage.getPath() + "/jcr:content/myComponent"; //path to component

Op5:-

<%@page import="org.apache.sling.commons.osgi.PropertiesUtil" %>
<% Boolean myProperty = PropertiesUtil.toBoolean(context.getProperties().get("myproperty"), false); %>

I hope this would help you a bit.

~kautuk



Kautuk Sahni

Avatar

Administrator

Did the answer posted helped you?

~kautuk



Kautuk Sahni