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