1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.event;
21
22 import org.apache.commons.beanutils.BeanUtils;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 import javax.faces.component.UIComponent;
27 import javax.faces.context.FacesContext;
28 import javax.faces.event.AbortProcessingException;
29 import javax.faces.event.ActionEvent;
30 import javax.faces.event.ActionListener;
31 import java.lang.reflect.InvocationTargetException;
32
33 public abstract class AbstractPopupActionListener implements ActionListener {
34
35 private static final Logger LOG = LoggerFactory.getLogger(AbstractPopupActionListener.class);
36
37 public void processAction(ActionEvent actionEvent) throws AbortProcessingException {
38 UIComponent popup = getPopup(actionEvent);
39 if (popup != null) {
40 if (LOG.isDebugEnabled()) {
41 LOG.debug("activated "
42 + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance()));
43 }
44
45 try {
46 BeanUtils.setProperty(popup, "activated", true);
47 } catch (IllegalAccessException e) {
48 LOG.error("", e);
49 } catch (InvocationTargetException e) {
50 LOG.error("", e);
51 }
52 }
53 }
54
55 protected abstract UIComponent getPopup(ActionEvent actionEvent);
56 }