1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.teeda.core.lifecycle.impl; |
17 | |
|
18 | |
import java.io.IOException; |
19 | |
|
20 | |
import javax.faces.FacesException; |
21 | |
import javax.faces.application.ViewHandler; |
22 | |
import javax.faces.context.FacesContext; |
23 | |
import javax.faces.el.EvaluationException; |
24 | |
import javax.faces.event.PhaseId; |
25 | |
import javax.faces.internal.scope.RedirectScope; |
26 | |
|
27 | |
import org.seasar.teeda.core.lifecycle.AbstractPhase; |
28 | |
import org.seasar.teeda.core.util.FacesContextUtil; |
29 | |
import org.seasar.teeda.core.util.PortletUtil; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 3 | public class RenderResponsePhase extends AbstractPhase { |
35 | |
|
36 | |
public void executePhase(FacesContext context) throws FacesException { |
37 | 2 | ViewHandler viewHandler = FacesContextUtil.getViewHandler(context); |
38 | |
try { |
39 | 2 | viewHandler.renderView(context, context.getViewRoot()); |
40 | 2 | } catch (IOException e) { |
41 | 1 | throw new FacesException(e.getMessage(), e); |
42 | 0 | } catch (EvaluationException ex) { |
43 | 0 | Throwable cause = ex.getCause(); |
44 | 0 | if (cause instanceof RuntimeException) { |
45 | 0 | throw (RuntimeException) cause; |
46 | 0 | } else if (cause instanceof Error) { |
47 | 0 | throw (Error) cause; |
48 | |
} else { |
49 | 0 | throw ex; |
50 | |
} |
51 | |
} finally { |
52 | 1 | synchronized (this) { |
53 | 2 | if (RedirectScope.isRedirecting(context)) { |
54 | 0 | if (!context.getResponseComplete()) { |
55 | 0 | String path = RedirectScope.getRedirectingPath(context); |
56 | 0 | RedirectScope.clearContext(context); |
57 | 0 | RedirectScope.setRedirectedPath(context, path); |
58 | |
} |
59 | |
} else { |
60 | |
|
61 | 2 | if (!PortletUtil.isPortlet(context)) { |
62 | 2 | RedirectScope.clearContext(context); |
63 | |
} |
64 | |
} |
65 | 2 | } |
66 | 1 | } |
67 | 1 | } |
68 | |
|
69 | |
protected PhaseId getCurrentPhaseId() { |
70 | 1 | return PhaseId.RENDER_RESPONSE; |
71 | |
} |
72 | |
|
73 | |
} |