use of org.apache.myfaces.tobago.internal.component.AbstractUITabGroup in project myfaces-tobago by apache.
the class TabGroupRenderer method processEvent.
@Override
public void processEvent(final ComponentSystemEvent event) {
final AbstractUITabGroup tabGroup = (AbstractUITabGroup) event.getComponent();
for (final UIComponent child : tabGroup.getChildren()) {
if (child instanceof AbstractUITab) {
final AbstractUITab tab = (AbstractUITab) child;
final FacesContext facesContext = FacesContext.getCurrentInstance();
final ClientBehaviors click = ClientBehaviors.click;
switch(tabGroup.getSwitchType()) {
case none:
break;
case client:
// todo: implement a client behavior which can call local scripts (respect CSP)
break;
case reloadTab:
final AjaxBehavior ajaxBehavior = new AjaxBehavior();
final Collection<String> ids = Collections.singleton(UINamingContainer.getSeparatorChar(facesContext) + tabGroup.getClientId(facesContext));
ajaxBehavior.setExecute(ids);
ajaxBehavior.setRender(ids);
tab.addClientBehavior(click.name(), ajaxBehavior);
break;
case reloadPage:
final AbstractUIEvent component = (AbstractUIEvent) ComponentUtils.createComponent(facesContext, Tags.event.componentType(), RendererTypes.Event, "_click");
component.setEvent(click);
tab.getChildren().add(component);
final EventBehavior eventBehavior = new EventBehavior();
eventBehavior.setFor(component.getId());
tab.addClientBehavior(click.name(), eventBehavior);
break;
default:
LOG.error("Unknown switch type: '{}'", tabGroup.getSwitchType());
}
}
}
}
Aggregations