KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > wstore > MessageTag


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Smart Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.wstore;
15
16 import java.util.*;
17 import java.sql.*;
18 import javax.servlet.*;
19 import javax.servlet.http.*;
20 import javax.servlet.jsp.*;
21 import javax.servlet.jsp.tagext.*;
22
23 import org.apache.log4j.Logger;
24
25 import org.compiere.util.Msg;
26
27 /**
28  * Message/Translation Tag.
29  * <cws:message txt="AD_Message"/>
30  *
31  * @author Jorg Janke
32  * @version $Id: MessageTag.java,v 1.3 2003/04/28 04:20:25 jjanke Exp $
33  */

34 public class MessageTag extends TagSupport
35 {
36     /** Logger */
37     private Logger log = Logger.getLogger (getClass());
38     /** Text */
39     private String JavaDoc m_txt;
40
41     /**
42      * Set text
43      * @param txt text to be translated
44      */

45     public void setTxt (String JavaDoc txt)
46     {
47         m_txt = txt;
48     } // setVar
49

50
51     /**
52      * Start Tag
53      * @return SKIP_BODY
54      * @throws JspException
55      */

56     public int doStartTag() throws JspException
57     {
58         if (m_txt != null && m_txt.length() > 0)
59         {
60             Properties ctx = JSPEnv.getCtx((HttpServletRequest)pageContext.getRequest());
61             String JavaDoc msg = Msg.translate(ctx, m_txt);
62             log.debug (m_txt + "->" + msg);
63             //
64
try
65             {
66                 JspWriter out = pageContext.getOut();
67                 out.print (msg);
68             }
69             catch (Exception JavaDoc e)
70             {
71                 throw new JspException(e);
72             }
73         }
74         return (SKIP_BODY);
75     } // doStartTag
76

77     /**
78      * End Tag
79      * @return EVAL_PAGE
80      * @throws JspException
81      */

82     public int doEndTag() throws JspException
83     {
84         return EVAL_PAGE;
85     } // doEndTag
86

87 } // MessageTag
88
Popular Tags