View Javadoc

1   package de.tivsource.page.admin.actions.others.picture;
2   
3   import java.util.List;
4   
5   import org.apache.logging.log4j.LogManager;
6   import org.apache.logging.log4j.Logger;
7   import org.apache.struts2.convention.annotation.Action;
8   import org.apache.struts2.convention.annotation.Actions;
9   import org.apache.struts2.convention.annotation.Result;
10  import org.apache.struts2.tiles.annotation.TilesDefinition;
11  import org.apache.struts2.tiles.annotation.TilesDefinitions;
12  import org.apache.struts2.tiles.annotation.TilesPutAttribute;
13  
14  import de.tivsource.ejb3plugin.InjectEJB;
15  import de.tivsource.page.admin.actions.EmptyAction;
16  import de.tivsource.page.dao.gallery.GalleryDaoLocal;
17  import de.tivsource.page.dao.picture.PictureDaoLocal;
18  import de.tivsource.page.entity.gallery.Gallery;
19  import de.tivsource.page.entity.picture.Picture;
20  
21  /**
22   * 
23   * @author Marc Michele
24   *
25   */
26  @TilesDefinitions({
27    @TilesDefinition(name="pictureAddForm",  extend = "adminTemplate", putAttributes = {
28      @TilesPutAttribute(name = "meta",       value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
29      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
30      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/picture/add_form.jsp")
31    }),
32    @TilesDefinition(name="pictureEditForm", extend = "adminTemplate", putAttributes = {
33      @TilesPutAttribute(name = "meta",       value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
34      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
35      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/picture/edit_form.jsp")
36    }),
37    @TilesDefinition(name="pictureDeleteForm", extend = "adminTemplate", putAttributes = {
38      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
39      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/picture/delete_form.jsp")
40    }),
41    @TilesDefinition(name="pictureForm", extend = "adminTemplate", putAttributes = {
42      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
43      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/picture/picture_form.jsp")
44    })
45  })
46  public class FormAction extends EmptyAction {
47  
48  	/**
49  	 * Serial Version UID.
50  	 */
51  	private static final long serialVersionUID = 667128497047812792L;
52  
53  	/**
54       * Statischer Logger der Klasse.
55       */
56      private static final Logger LOGGER = LogManager.getLogger(FormAction.class);
57  
58      @InjectEJB(name="PictureDao")
59      private PictureDaoLocal pictureDaoLocal;
60  
61      @InjectEJB(name="GalleryDao")
62      private GalleryDaoLocal galleryDaoLocal;
63  
64      private Picture picture;
65  
66      private String uncheckPicture;
67  
68      private String lang;
69  
70      public Picture getPicture() {
71          return picture;
72      }
73  
74  	public void setPicture(String uncheckPicture) {
75          this.uncheckPicture = uncheckPicture;
76      }
77  
78  	public String getLang() {
79  	    return lang;
80  	}
81  
82  	public void setLang(String lang) {
83  	    this.lang = lang;
84  	}
85  	
86  	@Override
87      @Actions({
88          @Action(
89          		value = "editForm", 
90          		results = { @Result(name = "success", type="tiles", location = "pictureEditForm") }
91          ),
92          @Action(
93          		value = "addForm", 
94          		results = { @Result(name = "success", type="tiles", location = "pictureAddForm") }
95          ),
96          @Action(
97          		value = "deleteForm", 
98          		results = { @Result(name = "success", type="tiles", location = "pictureDeleteForm") }
99          ),
100         @Action(
101                 value = "pictureForm", 
102                 results = { @Result(name = "success", type="tiles", location = "pictureForm") }
103         )
104     })
105     public String execute() throws Exception {
106     	LOGGER.info("execute() aufgerufen.");
107     	this.loadPageParameter();
108     	return SUCCESS;
109     }// Ende execute()
110 
111 	public List<Gallery> getGalleryList() {
112 		return galleryDaoLocal.findAll(0, galleryDaoLocal.countAll());
113 	}
114 	
115 	private void loadPageParameter() {
116 		if( uncheckPicture != null && uncheckPicture != "" && uncheckPicture.length() > 0) {
117 		    picture = pictureDaoLocal.findByUuid(uncheckPicture);
118 		} else {
119 		    picture = new Picture();
120 		}
121 	}// Ende loadPageParameter()
122 
123 }// Ende class