View Javadoc

1   package de.tivsource.page.admin.actions.others.message;
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.message.MessageDaoLocal;
15  import de.tivsource.page.entity.message.Message;
16  
17  /**
18   * 
19   * @author Marc Michele
20   *
21   */
22  @TilesDefinitions({
23    @TilesDefinition(name="messageView",  extend = "adminTemplate", putAttributes = {
24      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
25      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/message/view.jsp")
26    })
27  })
28  public class ViewAction extends EmptyAction {
29  
30  	/**
31  	 * Serial Version UID.
32  	 */
33      private static final long serialVersionUID = -2502111716063075247L;
34  
35      /**
36       * Statischer Logger der Klasse.
37       */
38      private static final Logger LOGGER = LogManager.getLogger(ViewAction.class);
39  
40      @InjectEJB(name="MessageDao")
41      private MessageDaoLocal messageDaoLocal;
42  
43      private Message message;
44  
45      private String uncheckMessage;
46  
47      public Message getMessage() {
48          return message;
49      }
50  
51  	public void setMessage(String uncheckMessage) {
52          this.uncheckMessage = uncheckMessage;
53      }
54  
55  	@Override
56      @Actions({
57          @Action(
58          		value = "view", 
59          		results = { @Result(name = "success", type="tiles", location = "messageView") }
60          )
61      })
62      public String execute() throws Exception {
63      	LOGGER.info("execute() aufgerufen.");
64      	this.loadPageParameter();
65      	return SUCCESS;
66      }// Ende execute()
67  
68  	private void loadPageParameter() {
69  		if( uncheckMessage != null && uncheckMessage != "" && uncheckMessage.length() > 0) {
70  		    message = messageDaoLocal.findByUuid(uncheckMessage);
71  		    message.setContent((message.getContent().replace("\n", "<br/>")));
72  		    
73  		}
74  	}// Ende loadPageParameter()
75  
76  }// Ende class