Created

Mar 28, 2012

Using the multifield in your cq5 component

Posted by Feike Visser

Here a small example how to use a multifield inside your component or in your OSGi-component.


When you have created a dialog with a multifield and you have entered some values, you see that the value itself is stored as a String-array.

multifield1

When you now want to access the values in your component, the following will not work :

1. ${properties.applicationProperties}

This will print the object-reference

2. <%=properties.get("applicationProperties","default")%>

This will print only the first entry of the String-array.

Here some samples that will give you a handle to loop through the values :

<!-- using JSTL in your component -->
<c:forEach var="element" items="${properties.applicationProperties}">
  In the loop ${element}
</c:forEach>

<!-- using Java-code -->
String[] applicationProperties = (String[]) getProperties().get("applicationProperties", String[].class);
        
for(String value: applicationProperties ) {
  // do something with the value
}



COMMENTS

  • By satish sapate - 7:29 PM on Jun 19, 2012   Reply
    I want to create side navigation and I am using multifield to create parent node but also I want to create the child for each parent for that how we can use multifield to create child node using multifield. Its nothing but I want to create multifield into multifield


    Thanks in advance
  • By photo booth nj - 4:58 PM on Apr 27, 2013   Reply
    Thanks for keeping us informed
  • By wedding photography nj - 9:39 PM on Apr 27, 2013   Reply
    Its great to see you taking the time to share this information
  • By Chambres d'hotes cassis - 5:11 AM on May 14, 2013   Reply
    Checking out this post advises me of my previous roomie! He/she regularly always kept teaching concerning this. I will onward this blog post to your man. Pretty sure god is actually heading to experience a good read. Acknowledge you for sharing! And also examine this: <a href="http://www.financeutile.com">financement participatif</a> and <a href="http://mathsmalin.fr/exercices10/6,aires-et-perimetres.html">exercice des aires et périmétre gratuit pour 6éme</a>.