return new Component(clazz, id, type.getName(), lifecycle, template, decorator, toInitParams(annotation.initParams()),
validators, events, eventInterceptors);
}
private Event toEventConfig(EventConfig annotation) {
Event event = new Event();
event.setExecutionPhase(annotation.phase());
event.setConfirm(annotation.confirm());
event.setInitParams(toInitParams(annotation.initParams()));
ArrayList<String> listeners = new ArrayList<String>();
for (Class<?> clazz : annotation.listeners()) {
listeners.add(clazz.getName());
}
if (annotation.name().length() > 0) {
event.setName(annotation.name());
} else if (annotation.listeners().length > 0) {
String name = annotation.listeners()[0].getSimpleName();
int idx = name.indexOf("ActionListener");
if (idx > -1) {
name = name.substring(0, idx);
}
event.setName(name);
}
event.setListeners(listeners);
event.setCsrfCheck(annotation.csrfCheck());
return event;
}