user and relationship type now editable and removeable. Generic error page for admin site
| /trunk/src/struts.xml |
|---|
| 20,7 → 20,7 |
| <result>/admin/userAddForm.jsp</result> |
| </action> |
| <action name="doUserAdd" method="addOrUpdate" class="ch.ffhs.webE.action.UserAction"> |
| <action name="doUserAdd" method="add" class="ch.ffhs.webE.action.UserAction"> |
| <result name="success">/admin/userAdd.jsp</result> |
| </action> |
| 32,13 → 32,7 |
| <result name="success" type="redirect">/admin/userList</result> |
| </action> |
| <action name="editUser" method="edit" class="ch.ffhs.webE.action.UserAction"> |
| <result name="success">/admin/userAddForm.jsp</result> |
| </action> |
| <!-- Relationship Type management --> |
| <action name="relTypeList" method="list" class="ch.ffhs.webE.action.RelationshipTypeAction"> |
| <result name="success">/admin/relTypeList.jsp</result> |
| 48,7 → 42,7 |
| <result>/admin/relTypeAddForm.jsp</result> |
| </action> |
| <action name="doRelTypeAdd" method="addOrUpdate" class="ch.ffhs.webE.action.RelationshipTypeAction"> |
| <action name="doRelTypeAdd" method="add" class="ch.ffhs.webE.action.RelationshipTypeAction"> |
| <result name="success" type="redirect">/admin/relTypeList</result> |
| </action> |
| 56,11 → 50,6 |
| <result name="success" type="redirect">/admin/relTypeList</result> |
| </action> |
| <action name="editRelType" method="edit" class="ch.ffhs.webE.action.RelationshipTypeAction"> |
| <result name="success">/admin/relTypeAddForm.jsp</result> |
| <result name="error">/admin/adminError.jsp</result> |
| </action> |
| </package> |
| /trunk/src/ch/ffhs/webE/dao/UserDAOImpl.java |
|---|
| 38,8 → 38,7 |
| e.printStackTrace(); |
| } |
| // If no user was checked, return an empty list to mitigate null pointer |
| // exceptions |
| //If no user was checked, return an empty list to mitigate null pointer exceptions |
| if (user == null) |
| { |
| user = new ArrayList<User>(); |
| 55,11 → 54,11 |
| * @return void |
| */ |
| @Override |
| public void saveOrUpdateUser(User user) |
| public void saveUser(User user) |
| { |
| try |
| { |
| session.saveOrUpdate(user); |
| session.save(user); |
| } |
| catch (Exception e) |
| { |
| 113,22 → 112,4 |
| } |
| return user; |
| } |
| /** |
| * Used to list a single user by Id. |
| */ |
| @Override |
| public User listUserById(int userId) |
| { |
| User user = null; |
| try |
| { |
| user = (User) session.get(User.class, userId); |
| } |
| catch (Exception e) |
| { |
| e.printStackTrace(); |
| } |
| return user; |
| } |
| } |
| /trunk/src/ch/ffhs/webE/dao/RelationshipTypeDAO.java |
|---|
| 8,9 → 8,8 |
| List<RelationshipType> listRelationshipTypes(); |
| boolean saveRelationshipType(RelationshipType relType); |
| boolean deleteRelationshipType(int relTypeID); |
| RelationshipType listRelTypeById(int relTypeID); |
| boolean saveOrUpdateRelType(RelationshipType relType); |
| } |
| /trunk/src/ch/ffhs/webE/dao/RelationshipTypeDAOImpl.java |
|---|
| 57,11 → 57,11 |
| * relationshipType |
| */ |
| @Override |
| public boolean saveOrUpdateRelType(RelationshipType relType) |
| public boolean saveRelationshipType(RelationshipType relType) |
| { |
| try |
| { |
| session.saveOrUpdate(relType); |
| session.save(relType); |
| return true; |
| } |
| catch (Exception e) |
| 83,9 → 83,8 |
| { |
| try |
| { |
| RelationshipType relType = (RelationshipType) session.get( |
| RelationshipType.class, relTypeID); |
| session.delete(relType); |
| User user = (User) session.get(RelationshipType.class, relTypeID); |
| session.delete(user); |
| return true; |
| } |
| catch (Exception e) |
| 95,24 → 94,4 |
| return false; |
| } |
| } |
| /** |
| * Used to get a relationship type by ID |
| */ |
| @Override |
| public RelationshipType listRelTypeById(int relTypeID) |
| { |
| RelationshipType relType = null; |
| try |
| { |
| relType = (RelationshipType) session.get(RelationshipType.class, |
| relTypeID); |
| } |
| catch (Exception e) |
| { |
| e.printStackTrace(); |
| // TODO: Logging |
| } |
| return relType; |
| } |
| } |
| /trunk/src/ch/ffhs/webE/dao/UserDAO.java |
|---|
| 4,16 → 4,10 |
| import ch.ffhs.webE.domain.User; |
| public interface UserDAO |
| { |
| public interface UserDAO { |
| List<User> listUser(); |
| void saveUser(User user); |
| User searchUsername(String username); |
| void deleteUser(int userId); |
| User listUserById(int userId); |
| void saveOrUpdateUser(User user); |
| } |
| /trunk/src/ch/ffhs/webE/action/RelationshipTypeAction.java |
|---|
| 31,9 → 31,9 |
| return relType; |
| } |
| public String addOrUpdate() |
| public String add() |
| { |
| relTypeDAO.saveOrUpdateRelType(relType); |
| relTypeDAO.saveRelationshipType(relType); |
| return SUCCESS; |
| } |
| 43,32 → 43,20 |
| return SUCCESS; |
| } |
| public String edit() |
| { |
| int id = getIdParameter(); |
| if (id > 0) |
| { |
| relType = relTypeDAO.listRelTypeById(id); |
| return SUCCESS; |
| } |
| else |
| { |
| return ERROR; |
| } |
| } |
| /** |
| * Gets the ID Parameter for update / delete requests |
| * deletes a relationshipType, gets the ID from the id parameter that was |
| * submitted |
| * |
| * @return int from the ID request. If not set or wrong, it gives back -1 |
| * @return String - either success or error |
| */ |
| private int getIdParameter() |
| public String delete() |
| { |
| HttpServletRequest request = (HttpServletRequest) ActionContext |
| .getContext().get(ServletActionContext.HTTP_REQUEST); |
| int id = -1; |
| //Make sure the ID from the request parameter is valid |
| int id = 0; |
| try |
| { |
| id = Integer.parseInt(request.getParameter("id")); |
| 75,22 → 63,9 |
| } |
| catch (Exception e) |
| { |
| // TODO: Logging - wrong parameter set |
| return ERROR; |
| } |
| return id; |
| } |
| /** |
| * deletes a relationshipType, gets the ID from the id parameter that was |
| * submitted |
| * |
| * @return String - either success or error |
| */ |
| public String delete() |
| { |
| int id = getIdParameter(); |
| // Check for malicious ID values |
| if (id > 0) |
| { |
| /trunk/src/ch/ffhs/webE/action/UserAction.java |
|---|
| 35,9 → 35,9 |
| * |
| * @return |
| */ |
| public String addOrUpdate() |
| public String add() |
| { |
| userDAO.saveOrUpdateUser(user); |
| userDAO.saveUser(user); |
| return SUCCESS; |
| } |
| 52,32 → 52,19 |
| return SUCCESS; |
| } |
| public String edit() |
| { |
| int id = getIdParameter(); |
| if (id > 0) |
| { |
| user = userDAO.listUserById(id); |
| return SUCCESS; |
| } |
| else |
| { |
| return ERROR; |
| } |
| } |
| /** |
| * Gets the ID Parameter for update / delete requests |
| * deletes a user, gets the ID from the "id" parameter that was submitted |
| * with the HTTP request |
| * |
| * @return int from the ID request. If not set or wrong, it gives back -1 |
| * @return String - either SUCCESS or ERROR constant |
| */ |
| private int getIdParameter() |
| public String delete() |
| { |
| HttpServletRequest request = (HttpServletRequest) ActionContext |
| .getContext().get(ServletActionContext.HTTP_REQUEST); |
| int id = -1; |
| int id = 0; |
| try |
| { |
| id = Integer.parseInt(request.getParameter("id")); |
| 84,23 → 71,9 |
| } |
| catch (Exception e) |
| { |
| // TODO: Logging - wrong parameter set |
| return ERROR; |
| } |
| return id; |
| } |
| /** |
| * deletes a user, gets the ID from the "id" parameter that was submitted |
| * with the HTTP request |
| * |
| * @return String - either SUCCESS or ERROR constant |
| */ |
| public String delete() |
| { |
| int id = getIdParameter(); |
| // Check for malicious ID values |
| if (id > 0) |
| { |
| /trunk/WebContent/admin/adminError.jsp |
|---|
| File deleted |
| Property changes: |
| Deleted: svn:mime-type |
| ## -1 +0,0 ## |
| -text/plain |
| \ No newline at end of property |
| Index: WebContent/admin/relTypeAdd.jsp |
| =================================================================== |
| --- WebContent/admin/relTypeAdd.jsp (revision 27) |
| +++ WebContent/admin/relTypeAdd.jsp (revision 26) |
| @@ -1,11 +1,13 @@ |
| -<html> |
| +<?xml version="1.0" encoding="ISO-8859-1" ?> |
| +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" |
| + pageEncoding="ISO-8859-1"%> |
| +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| +<html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| -<title>Beziehungstyp added</title> |
| +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> |
| +<title>Insert title here</title> |
| </head> |
| <body> |
| -<h1>Beziehungstyp hinzugefügt</h1> |
| -<p>Der Beziehungstyp wurde hinzugefügt</p> |
| -<p>TODO: Weiterleitung!!</p> |
| </body> |
| </html> |
| \ No newline at end of file |
| /trunk/WebContent/admin/relTypeList.jsp |
|---|
| 13,8 → 13,8 |
| </s:if> |
| <table> |
| <tr> |
| <th>Bezeichnung A =< B</th> |
| <th>Bezeichnung B =< A</th> |
| <th>Bezeichnung nach A</th> |
| <th>Bezeichnung nach B</th> |
| </tr> |
| <s:iterator value="relTypeList" status="stat"> |
| <tr> |
| 22,10 → 22,10 |
| <td><s:property value="nameTo" /></td> |
| <td><s:url id="editURL" action="editRelType"> |
| <s:param name="id" value="%{relationshipId}"></s:param> |
| <s:param name="id" value="%{id}"></s:param> |
| </s:url> <s:a href="%{editURL}">Ändern</s:a></td> |
| <td><s:url id="deleteURL" action="deleteRelType"> |
| <s:param name="id" value="%{relationshipId}"></s:param> |
| <s:param name="id" value="%{id}"></s:param> |
| </s:url> <s:a href="%{deleteURL}">Löschen</s:a></td> |
| </tr> |
| </s:iterator> |
| /trunk/WebContent/admin/relTypeAddForm.jsp |
|---|
| 8,9 → 8,8 |
| <h1>Beziehungstyp hinzufügen</h1> |
| <p>Bitte geben Sie die Daten für den Beziehungstypen ein</p> |
| <s:form action="doRelTypeAdd"> |
| <s:hidden name="relType.relationshipId" /> |
| <s:textfield name="relType.nameFrom" label="Name vom Ausgangspunkt (z.B. ist Vater von)" /> |
| <s:textfield name="relType.nameTo" label="Name vom Zielpunkt (z.B. ist Sohn von)" /> |
| <s:textfield name="nameFrom" label="Name vom Ausgangspunkt (z.B. ist Vater von)" /> |
| <s:textfield name="nameTo" label="Name vom Zielpunkt (z.B. ist Sohn von)" /> |
| <s:submit value="Add" /> |
| </s:form> |
| </body> |
| /trunk/WebContent/admin/userAdd.jsp |
|---|
| 1,6 → 1,6 |
| <html> |
| <head> |
| <title>User added</title> |
| <title>User bearbeiten</title> |
| </head> |
| <body> |
| /trunk/WebContent/admin/userAddForm.jsp |
|---|
| 8,15 → 8,13 |
| <h1>User hinzufügen</h1> |
| <p>Bitte geben Sie die Benutzerdaten ein</p> |
| <s:form action="doUserAdd"> |
| <s:hidden name="user.id" /> |
| <s:textfield name="user.username" label="User Name" /> |
| <s:password name="user.password" label="Password" /> |
| <s:textfield name="user.firstname" label="Vorname" /> |
| <s:textfield name="user.lastname" label="Nachname" /> |
| <s:checkbox name="user.admin" |
| <s:textfield name="username" label="User Name" /> |
| <s:password name="password" label="Password" /> |
| <s:textfield name="firstname" label="Vorname" /> |
| <s:textfield name="lastname" label="Nachname" /> |
| <s:checkbox name="admin" |
| label="Soll der User admin sein?" /> |
| <s:submit value="Add" /> |
| </s:form> |
| </body> |
| </html> |