I have a method to dynamically create objects of type MenuItem based on a list of operations that I have created. Within that method I have the following FOR loop:
for(OperacionConfigurableDTO oc : this.plantillaPrincipalFichaPacienteVM.getListaOperacionesConfigurables()){
if(comprobarEstado(oc) && comprobarPerfil(oc) && comprobarActiva(oc)){
Menuitem m = new Menuitem();
AImage imagen = null;
try {
imagen = new AImage("", oc.getIcono());
m.setImageContent(imagen);
} catch (IOException e) {
e.printStackTrace();
}
m.setImageContent(imagen);
m.setTooltiptext(oc.getNombre());
m.setStyle("text-align: center;");
m.setWidth("50px");
m.addEventListener("onClick",new EventListener<MouseEvent>(){
@Override
public void onEvent(MouseEvent event) throws Exception {
System.out.println("PULSADO BOTON");
}
});
menuOpciones.appendChild(m);
contadorOperaciones++;
}
}
Inside that onClick that I am creating for each element (since ZK's MenuItem does not bring it), I need to execute a URL, but in the background, without opening a new tab in my browser (in case I want to make a call to a service). But after a long time of attempts I do not get it, I just call the URL opening a new tab.