我动态创建我的面板,我也想动态添加 ajax 关闭侦听器,但对我不起作用。对于每个面板:
int u = _memosId.get(i);
Panel panel = (Panel)_application.createComponent(_context, "org.primefaces.component.Panel", "org.primefaces.component.PanelRenderer");
panel.setId("mymemo_" + String.valueOf(u));
panel.setHeader(_userNames.get(i));
panel.setClosable(true);
panel.setToggleable(true);
HtmlOutputText memo = new HtmlOutputText();
memo.setValue(_userMemos.get(i));
panel.getChildren().add(memo);
AjaxBehavior ajaxBehavior =(AjaxBehavior)_context.getApplication().createBehavior(AjaxBehavior.BEHAVIOR_ID);
ajaxBehavior.addAjaxBehaviorListener(new ClosePanelListener());
ajaxBehavior.setTransient(true);
panel.addClientBehavior("close", ajaxBehavior);
_column1.addWidget(panel.getId());
getDashboard().getChildren().add(panel);
和我的班级听众:
private static class ClosePanelListener implements AjaxBehaviorListener
{
@Override
public void processAjaxBehavior(AjaxBehaviorEvent event) throws AbortProcessingException
{
System.out.println("----------->>>>>>>>>>AjaxListener CALLED!!! ");
}
}
未调用侦听器。