4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
Users.java
Go to the documentation of this file.
1 /*
2  * Project: Server for annotations sharing
3  * Author: Ing. Jaroslav Dytrych idytrych@fit.vutbr.cz
4  * File: Users.java
5  * Description: Backbean for page with administration of users
6  */
7 
8 /**
9  * @file Users.java
10  *
11  * @brief Backbean for page with administration of users
12  */
13 
14 package cz.vutbr.fit.knot.annotations.web;
15 
18 import java.io.Serializable;
19 import java.util.List;
20 import javax.faces.bean.ManagedBean;
21 import javax.faces.bean.SessionScoped;
22 import javax.faces.component.html.HtmlDataTable;
23 
24 /**
25  * Backbean for page with administration of users
26  *
27  * @brief Backbean for administration of users
28  * @author idytrych
29  */
30 @ManagedBean
31 @SessionScoped
32 public class Users implements Serializable {
33  /**
34  * Table with users
35  */
36  private HtmlDataTable listTable;
37  /**
38  * User selected in the table
39  */
40  private User user;
41 
42  /**
43  * Constructor
44  */
45  public Users() {
46  this.user = new User();
47  }
48 
49  /**
50  * Gets user selected in the table
51  *
52  * @return Returns user selected in the table
53  */
54  public User getUser() {
55  return user;
56  }
57 
58  /**
59  * Sets user selected in the table
60  *
61  * @param user
62  */
63  public void setUser(User user) {
64  this.user = user;
65  }
66 
67  /**
68  * Gets table with user
69  *
70  * @return Returns table with user
71  */
72  public HtmlDataTable getListTable() {
73  return listTable;
74  }
75 
76  /**
77  * Sets table with user
78  *
79  * @param listTable Table with user
80  */
81  public void setListTable(HtmlDataTable listTable) {
82  this.listTable = listTable;
83  }
84 
85  /**
86  * Gets list of all existing users
87  *
88  * @return Returns list of all existing user
89  */
90  public List<User> getUsersList() {
91  @SuppressWarnings("unchecked")
92  List<User> retList = AppBean.getPersistenceManager().getEntitiesByName("User");
93 
94  return retList;
95  }
96 
97  /**
98  * Action listener for edit links in table
99  *
100  * @return Returns page outcome to go to editing page
101  */
102  public String actionEdit() {
103  // get selected row from table
104  user = (User) listTable.getRowData();
105  // pass selected user through the session
106  SessionManager.getSession().setEditedUser(user);
107  SessionManager.getSession().setFormBackup(null);
108  return "editUser";
109  }
110 
111  /**
112  * Action listener for delete links in table
113  *
114  * @return Returns page outcome to go to deleting page
115  */
116  public String actionDelete() {
117  user = (User) listTable.getRowData();
118  SessionManager.getSession().setEditedUser(user);
119  return "deleteUser";
120  }
121 
122  /**
123  * Action listener for show settings of user
124  *
125  * @return Returns page outcome to go to show settings page
126  */
127  public String actionShowSettings() {
128  user = (User) listTable.getRowData();
129  SessionManager.getSession().setEditedUser(user);
130  SessionManager.getSession().setEditedSetting(null);
131  return "userSettings";
132  }
133 } // public class Users
134 
Singleton for storing global variables.
Definition: AppBean.java:47
Backbean for administration of users.
Definition: Users.java:32
Class representing user.
Definition: User.java:51
void setListTable(HtmlDataTable listTable)
Definition: Users.java:81