1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package olr.presentation;
18
19 import org.w3c.dom.html.HTMLAnchorElement;
20
21 import com.lutris.appserver.server.httpPresentation.ClientPageRedirectException;
22 import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
23
24 /***
25 * @version $Id: UnsavedChanges.java,v 1.1 2004/08/03 08:33:53 roku Exp $
26 */
27 public class UnsavedChanges extends ExtendedHttpPresentation {
28
29 public UnsavedChanges() {
30 }
31
32 public boolean loggedInUserRequired() {
33 return true;
34 }
35
36 public String handleDefault() throws HttpPresentationException {
37 return showPage(true);
38 }
39
40 public String handleSaveMenu() throws HttpPresentationException {
41 try {
42 getSessionData().getCourseViewers().save();
43 } catch (Exception e) {
44 showPage(true);
45 }
46
47 throw new ClientPageRedirectException("Welcome1.po?event=Restart");
48 }
49
50 public String handleSaveLogout() throws HttpPresentationException {
51 try {
52 getSessionData().getCourseViewers().save();
53 } catch (Exception e) {
54 showPage(true);
55 }
56 throw new ClientPageRedirectException("Login.po?event=Logout");
57 }
58
59 public String handleMenu() {
60 return showPage(false);
61 }
62
63 public String handleLogout() {
64 return showPage(true);
65 }
66
67 public String showPage(boolean logout) {
68 UnsavedChangesHTML page = new UnsavedChangesHTML();
69 if (logout) {
70 HTMLAnchorElement yes = page.getElementYes();
71 HTMLAnchorElement no = page.getElementNo();
72 yes.setAttribute("href", "UnsavedChanges.po?event=SaveLogout");
73 no.setAttribute("href", "Login.po?event=Logout");
74 }
75 if (getSessionData().isChanged()) {
76 getSessionData().setChanged(false);
77 return page.toDocument();
78 } else
79 throw new ClientPageRedirectException(logout ? "Login.po?event=Logout"
80 : "Welcome1.po?event=Restart");
81 }
82 }