Get Tag data
I've a multifield where-in I can add multiple tags. Now what I'm trying is to fetch the title of the tag. Attached are the screenshots of the dialog.
Resource Type of the field is : /libs/cq/gui/components/coral/common/form/tagfield

This is the method with which I had tried - Problem is it throws null pointer exception.
private void getCourses(List<String> coursesType, List<String> coursesTypeList) {
TagManager tagManager;
Iterator<String> coursesubjectList = coursesType.iterator();
while (coursesubjectList.hasNext()) {
resourceResolver = request.getResourceResolver();
tagManager = resourceResolver.adaptTo(TagManager.class);
Tag tag = tagManager.resolve(coursesubjectList.next());
if(tag != null){
coursesTypeList.add(tag.getTitle());
}
}
}
Please suggest any corrections or you can even help me with the reqd code snippet.