Rev 34 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 34 | Rev 37 | ||
---|---|---|---|
Line 6... | Line 6... | ||
6 | import javax.servlet.http.HttpServletRequest; |
6 | import javax.servlet.http.HttpServletRequest; |
7 | 7 | ||
8 | import org.apache.struts2.StrutsStatics; |
8 | import org.apache.struts2.StrutsStatics; |
9 | 9 | ||
10 | import ch.ffhs.webE.dao.RelationshipTypeDAO; |
10 | import ch.ffhs.webE.dao.RelationshipTypeDAO; |
11 | import ch.ffhs.webE.dao.RelationshipTypeDAOImpl; |
- | |
12 | import ch.ffhs.webE.domain.RelationshipType; |
11 | import ch.ffhs.webE.domain.RelationshipType; |
13 | 12 | ||
14 | import com.opensymphony.xwork2.Action; |
13 | import com.opensymphony.xwork2.Action; |
15 | import com.opensymphony.xwork2.ActionContext; |
14 | import com.opensymphony.xwork2.ActionContext; |
16 | import com.opensymphony.xwork2.ActionSupport; |
15 | import com.opensymphony.xwork2.ActionSupport; |
Line 22... | Line 21... | ||
22 | 21 | ||
23 | private static final long serialVersionUID = -3644691864156792139L; |
22 | private static final long serialVersionUID = -3644691864156792139L; |
24 | 23 | ||
25 | private RelationshipType relType = new RelationshipType(); |
24 | private RelationshipType relType = new RelationshipType(); |
26 | private List<RelationshipType> relTypeList = new ArrayList<RelationshipType>(); |
25 | private List<RelationshipType> relTypeList = new ArrayList<RelationshipType>(); |
27 | private final RelationshipTypeDAO relTypeDAO = new RelationshipTypeDAOImpl(); |
26 | private final RelationshipTypeDAO relTypeDAO = new RelationshipTypeDAO(); |
- | 27 | ||
- | 28 | public boolean edit = false; |
|
- | 29 | public boolean added = false; |
|
- | 30 | public RelationshipType savedRelType; |
|
28 | 31 | ||
29 | @Override |
32 | @Override |
30 | public RelationshipType getModel() |
33 | public RelationshipType getModel() |
31 | {
|
34 | {
|
32 | return this.relType; |
35 | return this.relType; |
33 | }
|
36 | }
|
34 | 37 | ||
35 | public String addOrUpdate() |
38 | public String addOrUpdate() |
36 | {
|
39 | {
|
37 | this.relTypeDAO.saveOrUpdateRelType(this.relType); |
40 | this.relTypeDAO.saveOrUpdate(this.relType); |
38 | return Action.SUCCESS; |
41 | return Action.SUCCESS; |
39 | }
|
42 | }
|
40 | 43 | ||
41 | public String list() |
44 | public String list() |
42 | {
|
45 | {
|
43 | this.relTypeList = this.relTypeDAO.getRelTypes(); |
46 | this.relTypeList = this.relTypeDAO.getList(); |
44 | return Action.SUCCESS; |
47 | return Action.SUCCESS; |
45 | }
|
48 | }
|
46 | 49 | ||
47 | public String edit() |
50 | public String edit() |
48 | {
|
51 | {
|
49 | int id = this.getIdParameter(); |
52 | int id = this.getIdParameter(); |
50 | 53 | ||
- | 54 | String result = Action.ERROR; |
|
51 | if (id > 0) |
55 | if (id > 0) |
52 | {
|
56 | {
|
53 | this.relType = this.relTypeDAO.getRelTypeById(id); |
57 | this.relType = this.relTypeDAO.getById(id); |
54 | return Action.SUCCESS; |
58 | this.edit = true; |
55 | }
|
- | |
56 | else
|
- | |
57 | {
|
- | |
58 | return Action.ERROR; |
59 | result = Action.SUCCESS; |
59 | }
|
60 | }
|
- | 61 | ||
- | 62 | this.list(); |
|
- | 63 | ||
- | 64 | return result; |
|
60 | }
|
65 | }
|
61 | 66 | ||
62 | /**
|
67 | /**
|
63 | * Gets the ID Parameter for update / delete requests
|
68 | * Gets the ID Parameter for update / delete requests
|
64 | *
|
69 | *
|
Line 93... | Line 98... | ||
93 | int id = this.getIdParameter(); |
98 | int id = this.getIdParameter(); |
94 | 99 | ||
95 | // Check for malicious ID values
|
100 | // Check for malicious ID values
|
96 | if (id > 0) |
101 | if (id > 0) |
97 | {
|
102 | {
|
98 | this.relTypeDAO.deleteRelationshipType(id); |
103 | this.relTypeDAO.delete(id); |
99 | return Action.SUCCESS; |
104 | return Action.SUCCESS; |
100 | }
|
105 | }
|
101 | else
|
106 | else
|
102 | {
|
107 | {
|
103 | return Action.ERROR; |
108 | return Action.ERROR; |