1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.apache.struts.webapp.example2;
24
25
26 import java.io.IOException;
27 import javax.faces.FacesException;
28 import javax.faces.context.FacesContext;
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31
32
33 /**
34 * <p>Backing bean for the <code>loggedoff.jsp</code> page.</p>
35 */
36
37 public class LoggedOff {
38
39
40
41
42
43 private static final Log log = LogFactory.getLog(LoggedOff.class);
44
45
46
47
48
49 /**
50 * <p>Begin the process of registering a new user.</p>
51 */
52 public String register() {
53
54 FacesContext context = FacesContext.getCurrentInstance();
55 if (log.isDebugEnabled()) {
56 log.debug("register(" + context + ")");
57 }
58 forward(context, "/editRegistration.do?action=Create");
59 return (null);
60
61 }
62
63
64 /**
65 * <p>Begin the process of logging on.</p>
66 */
67 public String logon() {
68
69 FacesContext context = FacesContext.getCurrentInstance();
70 if (log.isDebugEnabled()) {
71 log.debug("logon(" + context + ")");
72 }
73 forward(context, "/editLogon.do");
74 return (null);
75
76 }
77
78
79
80
81
82 /**
83 * <p>Forward to the specified URL and mark this response as having
84 * been completed.</p>
85 *
86 * @param context <code>FacesContext</code> for the current request
87 * @param url Context-relative URL to forward to
88 *
89 * @exception FacesException if any error occurs
90 */
91 private void forward(FacesContext context, String url) {
92
93 try {
94 context.getExternalContext().dispatch(url);
95 } catch (IOException e) {
96 throw new FacesException(e);
97 } finally {
98 context.responseComplete();
99 }
100
101 }
102
103
104 }