1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.teeda.core.application; |
17 | |
|
18 | |
import java.io.IOException; |
19 | |
|
20 | |
import javax.faces.component.ActionSource; |
21 | |
import javax.faces.context.ExternalContext; |
22 | |
import javax.faces.context.FacesContext; |
23 | |
import javax.faces.el.EvaluationException; |
24 | |
import javax.faces.el.MethodBinding; |
25 | |
import javax.faces.event.AbortProcessingException; |
26 | |
import javax.faces.event.ActionEvent; |
27 | |
import javax.faces.event.ActionListener; |
28 | |
|
29 | |
import org.seasar.framework.log.Logger; |
30 | |
import org.seasar.teeda.core.util.ErrorPageManager; |
31 | |
import org.seasar.teeda.core.util.MethodBindingUtil; |
32 | |
import org.seasar.teeda.core.util.NavigationHandlerUtil; |
33 | |
import org.seasar.teeda.core.util.NullErrorPageManagerImpl; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 0 | public class ActionListenerImpl implements ActionListener { |
39 | |
|
40 | 0 | private static Logger logger = Logger.getLogger(ActionListenerImpl.class); |
41 | |
|
42 | |
public static final String errorManager_BINDING = "bindingType=may"; |
43 | |
|
44 | 0 | private ErrorPageManager errorPageManager = new NullErrorPageManagerImpl(); |
45 | |
|
46 | |
public void processAction(ActionEvent actionEvent) |
47 | |
throws AbortProcessingException { |
48 | 0 | FacesContext context = FacesContext.getCurrentInstance(); |
49 | 0 | ActionSource actionSource = (ActionSource) actionEvent.getComponent(); |
50 | 0 | MethodBinding mb = actionSource.getAction(); |
51 | 0 | String fromAction = null; |
52 | 0 | String outcome = null; |
53 | 0 | if (mb != null) { |
54 | 0 | fromAction = mb.getExpressionString(); |
55 | |
try { |
56 | 0 | outcome = MethodBindingUtil.invoke(mb, context); |
57 | 0 | processAfterInvoke(context, fromAction, outcome); |
58 | 0 | } catch (EvaluationException ex) { |
59 | 0 | Throwable cause = ex.getCause(); |
60 | |
try { |
61 | 0 | ExternalContext extContext = context.getExternalContext(); |
62 | 0 | if (errorPageManager.handleException(cause, context, |
63 | |
extContext)) { |
64 | 0 | context.responseComplete(); |
65 | |
} else { |
66 | 0 | throw ex; |
67 | |
} |
68 | 0 | } catch (IOException ioe) { |
69 | 0 | logger.log(ioe); |
70 | 0 | throw ex; |
71 | 0 | } |
72 | 0 | } |
73 | |
} |
74 | 0 | NavigationHandlerUtil.handleNavigation(context, fromAction, outcome); |
75 | 0 | context.renderResponse(); |
76 | 0 | } |
77 | |
|
78 | |
protected void processAfterInvoke(FacesContext context, String fromAction, |
79 | |
String outcome) { |
80 | 0 | } |
81 | |
|
82 | |
public ErrorPageManager getErrorPageManager() { |
83 | 0 | return errorPageManager; |
84 | |
} |
85 | |
|
86 | |
public void setErrorPageManager(ErrorPageManager errorPageManager) { |
87 | 0 | this.errorPageManager = errorPageManager; |
88 | 0 | } |
89 | |
|
90 | |
} |