How to get node properties from path in a multifield
I am using a multi field where pathfield is the input of the dialog....From this path i need to fetch its node properties to get its jcr:title,jcr:description......
Please help me ASAP.....
<%@ page import="org.apache.sling.commons.json.JSONObject" %>
<%@ page import="java.io.PrintWriter" %>
<%@include file="/libs/foundation/global.jsp" %>
<%@page session="false" %>
<div style="display: block; border-style: solid; border-width: 1px; margin: 10px; padding: 10px">
<b>Multi Field Sample Dashboard</b>
<br><br>
///Code for multifield
<%
try
{
String[] dashboards = { "iItems", "uItems" } ;
for(String dash : dashboards)
{
Property property = null;
if (currentNode.hasProperty(dash))
{
property = currentNode.getProperty(dash);
}
if (property != null)
{
JSONObject obj = null;
Value[] values = null;
if (property.isMultiple())
{
values = property.getValues();
}
else
{
values = new Value[1];
values[0] = property.getValue();
}
for (Value val : values)
{
obj = new JSONObject(val.getString());
%>
/////This is my code to convert path to node...
<%
String componentPath = "<%=obj.get("path")%>/jcr:content"; //path to component
Node node = resourceResolver.getResource(componentPath).adaptTo(Node.class);
String title = node.getProperty("jcr:title").getString();
String text = node.getProperty("jcr:primaryType").getString();
%>
<br><br>
<%
}
} else {
%>
<br><br>
<%
}
}
}
catch (Exception e)
{
e.printStackTrace(new PrintWriter(out));
}
%>
</div>
After giving my code inside the loop ,,,the whole loop is getting error .what changes do i need to make in this code to get the path from dialog and fetch its node properties.........
