View Javadoc

1   package de.tivsource.page.admin.actions.system.captcha;
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.common.captcha.Captcha;
15  import de.tivsource.page.dao.captcha.CaptchaDaoLocal;
16  
17  /**
18   * 
19   * @author Marc Michele
20   *
21   */
22  @TilesDefinitions({
23    @TilesDefinition(name="captchaAddForm",  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/captcha/add_form.jsp")
27    }),
28    @TilesDefinition(name="captchaEditForm", 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/captcha/edit_form.jsp")
32    }),
33    @TilesDefinition(name="captchaDeleteForm", 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/captcha/delete_form.jsp")
36    })
37  })
38  public class FormAction extends EmptyAction {
39  
40      /**
41       * Serial Version UID.
42       */
43      private static final long serialVersionUID = 2077185860382503376L;
44  
45      /**
46       * Statischer Logger der Klasse.
47       */
48      private static final Logger LOGGER = LogManager.getLogger(FormAction.class);
49  
50      @InjectEJB(name="CaptchaDao")
51      private CaptchaDaoLocal captchaDaoLocal;
52  
53      private Captcha captcha;
54  
55      private String uncheckCaptcha;
56  
57      public Captcha getCaptcha() {
58          return captcha;
59      }
60  
61      public void setCaptcha(String uncheckCaptcha) {
62          this.uncheckCaptcha = uncheckCaptcha;
63      }
64  
65      @Override
66      @Actions({
67          @Action(
68                  value = "editForm",
69                  results = { @Result(name = "success", type="tiles", location = "captchaEditForm") }
70          ),
71          @Action(
72                  value = "addForm",
73                  results = { @Result(name = "success", type="tiles", location = "captchaAddForm") }
74          ),
75          @Action(
76                  value = "deleteForm",
77                  results = { @Result(name = "success", type="tiles", location = "captchaDeleteForm") }
78          )
79      })
80      public String execute() throws Exception {
81          LOGGER.info("execute() aufgerufen.");
82          this.loadPageParameter();
83          return SUCCESS;
84      }// Ende execute()
85  
86      private void loadPageParameter() {
87          if( uncheckCaptcha != null && uncheckCaptcha != "" && uncheckCaptcha.length() > 0) {
88              captcha = captchaDaoLocal.findByUuid(uncheckCaptcha);
89          } else {
90              captcha = new Captcha();
91          }
92      }// Ende loadPageParameter()
93  
94  }// Ende class