1 package de.tivsource.page.admin.actions.system.property;
2
3 import org.apache.logging.log4j.LogManager;
4 import org.apache.logging.log4j.Logger;
5 import org.apache.struts2.convention.annotation.Action;
6 import org.apache.struts2.convention.annotation.Actions;
7 import org.apache.struts2.convention.annotation.Result;
8 import org.apache.struts2.tiles.annotation.TilesDefinition;
9 import org.apache.struts2.tiles.annotation.TilesDefinitions;
10 import org.apache.struts2.tiles.annotation.TilesPutAttribute;
11
12 import de.tivsource.ejb3plugin.InjectEJB;
13 import de.tivsource.page.admin.actions.EmptyAction;
14 import de.tivsource.page.dao.property.PropertyDaoLocal;
15 import de.tivsource.page.entity.property.Property;
16
17
18
19
20
21
22 @TilesDefinitions({
23 @TilesDefinition(name="propertyAddForm", extend = "adminTemplate", putAttributes = {
24 @TilesPutAttribute(name = "meta", value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
25 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/system.jsp"),
26 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/property/add_form.jsp")
27 }),
28 @TilesDefinition(name="propertyEditForm", extend = "adminTemplate", putAttributes = {
29 @TilesPutAttribute(name = "meta", value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
30 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/system.jsp"),
31 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/property/edit_form.jsp")
32 }),
33 @TilesDefinition(name="propertyDeleteForm", extend = "adminTemplate", putAttributes = {
34 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/system.jsp"),
35 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/property/delete_form.jsp")
36 })
37 })
38 public class FormAction extends EmptyAction {
39
40
41
42
43 private static final long serialVersionUID = 2077185860382503376L;
44
45
46
47
48 private static final Logger LOGGER = LogManager.getLogger(FormAction.class);
49
50 @InjectEJB(name="PropertyDao")
51 private PropertyDaoLocal propertyDaoLocal;
52
53 private Property property;
54
55 private String uncheckProperty;
56
57 public Property getProperty() {
58 return property;
59 }
60
61 public void setProperty(String uncheckProperty) {
62 this.uncheckProperty = uncheckProperty;
63 }
64
65 @Override
66 @Actions({
67 @Action(
68 value = "editForm",
69 results = { @Result(name = "success", type="tiles", location = "propertyEditForm") }
70 ),
71 @Action(
72 value = "addForm",
73 results = { @Result(name = "success", type="tiles", location = "propertyAddForm") }
74 ),
75 @Action(
76 value = "deleteForm",
77 results = { @Result(name = "success", type="tiles", location = "propertyDeleteForm") }
78 )
79 })
80 public String execute() throws Exception {
81 LOGGER.info("execute() aufgerufen.");
82 this.loadPageParameter();
83 return SUCCESS;
84 }
85
86 private void loadPageParameter() {
87 if( uncheckProperty != null && uncheckProperty != "" && uncheckProperty.length() > 0) {
88 property = propertyDaoLocal.findByKey(uncheckProperty);
89 } else {
90 property = new Property();
91 }
92 }
93
94 }