Sorry if this is a basic question, as I am quite new to AEM.
I have a cq dialog
allowing multiple tags to be entered.
<tags
cq:showOnCreate="{Boolean}true"
jcr:primaryType="nt:unstructured"
sling:resourceType="/libs/cq/gui/components/coral/common/form/tagfield"
allowCreate="{Boolean}true"
fieldLabel="Tags to add"
metaType="tags"
multiple="true" <====================
name="./metaData/TAGS"/>
I am trying to retrieve the two tags above in my WorkflowProcess as below:
@Component(
//...
)
public class TagStep implements WorkflowProcess {
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap processArguments) {
try {
//...
List<String> tagslist = new ArrayList();
List<String> tags = processArguments.get("TAGS",tagslist);
// Nothing logged here <=======
for (String tag: tags) {
LOG.info(tag);
}
//...
} catch (Exception e){
LOG.info("\n ERROR {} ",e.getMessage());
}
}
}
There is no output when I try to log tag
in the loop above, probably the return type of List<String>
cannot be converted.
What is the proper return type when using multiple="true"
, and how to use processArguments.get
to get the values?
Btw my code was based on the tutorial here.
Thank you,
After looking into the source implementation, it is using an Array, not a List. so here is how to retrieve the passed in data.
Node node = (Node) session.getItem(path);
String[] cars = {};
String[] tags = processArguments.get("TAGS",cars);
node.setProperty("cq:tags", tags);