Esta conversación ha sido bloqueada debido a la inactividad. Cree una nueva publicación.
Nivel 1
Nivel 2
Iniciar sesión en la comunidad
Iniciar sesión para ver todas las insignias
Esta conversación ha sido bloqueada debido a la inactividad. Cree una nueva publicación.
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.
¡Resuelto! Ir a solución.
Los temas ayudan a categorizar el contenido de la comunidad e incrementan la posibilidad de encontrar contenido relevante.
Vistas
Respuestas
Total de me gusta
Hi @arindam6600 ,
Can you please check if your resourceResolver object is null?
Also refer this code: https://gist.github.com/ksurendra/900b2c5ce943fd85112e4de376aaaf20
Regards,
Santosh
Vistas
Respuestas
Total de me gusta
Hi @arindam6600 ,
Can you please check if your resourceResolver object is null?
Also refer this code: https://gist.github.com/ksurendra/900b2c5ce943fd85112e4de376aaaf20
Regards,
Santosh
Vistas
Respuestas
Total de me gusta
Hi @arindam6600
I would suggest you to use tagpicker instead of using tagfield. It allows you to select multiple tags so you don't need to use multifield with tagfield.
sling:resourceType:cq/gui/components/common/tagspicker
Below code snippet should work
@Inject private String[] tags; private void getCourses(String[] tags, List<String> coursesTypeList) { resourceResolver = request.getResourceResolver(); TagManager tagManager = resourceResolver.adaptTo(TagManager.class); for (String tag: tags) { Tag tag = tagManager.resolve(tag); if(tag != null){ coursesTypeList.add(tag.getTitle()); } } }
Vistas
Respuestas
Total de me gusta
Vistas
me gusta
Respuestas
Vistas
me gusta
Respuestas