KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > module > admininterface > commands > MessageCommand


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.module.admininterface.commands;
14
15 import info.magnolia.cms.i18n.Messages;
16 import info.magnolia.cms.i18n.MessagesManager;
17 import info.magnolia.cms.i18n.MessagesUtil;
18 import info.magnolia.cms.util.AlertUtil;
19 import info.magnolia.commands.MgnlCommand;
20 import info.magnolia.context.Context;
21
22 import org.apache.commons.lang.StringUtils;
23
24
25 /**
26  * A command setting a message using the AlertUtil
27  * @author Philipp Bracher
28  * @version $Revision:6423 $ ($Author:scharles $)
29  */

30 public class MessageCommand extends MgnlCommand {
31
32     /**
33      * The message
34      */

35     private String JavaDoc message = "";
36
37     private String JavaDoc i18nBasename = MessagesManager.DEFAULT_BASENAME;
38
39     /**
40      * @see info.magnolia.commands.MgnlCommand#execute(info.magnolia.context.Context)
41      */

42     public boolean execute(Context context) throws Exception JavaDoc {
43         if (StringUtils.isNotEmpty(message)) {
44             Messages msgs = MessagesUtil.chainWithDefault(this.getI18nBasename());
45             AlertUtil.setMessage(msgs.getWithDefault(message, message));
46         }
47         return true;
48     }
49
50     /**
51      * @return Returns the message.
52      */

53     public String JavaDoc getMessage() {
54         return this.message;
55     }
56
57     /**
58      * @param message The message to set.
59      */

60     public void setMessage(String JavaDoc message) {
61         this.message = message;
62     }
63
64     /**
65      * @return Returns the i18nBasename.
66      */

67     public String JavaDoc getI18nBasename() {
68         return this.i18nBasename;
69     }
70
71     /**
72      * @param basename The i18nBasename to set.
73      */

74     public void setI18nBasename(String JavaDoc basename) {
75         this.i18nBasename = basename;
76     }
77
78 }
79
Popular Tags