Source Code Cross Referenced for MsgFmtTag.java in  » Portal » Open-Portal » com » sun » portal » wireless » taglibs » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.wireless.taglibs.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *
003:         * $Id: MsgFmtTag.java,v 1.5 2005/09/21 10:53:32 dg154973 Exp $
004:         * Copyright 2005 Sun Microsystems, Inc. All
005:         * rights reserved. Use of this product is subject
006:         * to license terms. Federal Acquisitions:
007:         * Commercial Software -- Government Users
008:         * Subject to Standard License Terms and
009:         * Conditions.
010:         *
011:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
012:         * are trademarks or registered trademarks of Sun Microsystems,
013:         * Inc. in the United States and other countries.
014:         * MsgFragmentTag.java
015:         *
016:         * MsgFmtTag.java
017:         *
018:         * Created on February 25, 2005, 10:00 AM
019:         */
020:
021:        package com.sun.portal.wireless.taglibs.util;
022:
023:        import java.io.IOException;
024:
025:        import java.util.Map;
026:        import java.util.HashMap;
027:        import java.util.ResourceBundle;
028:        import java.util.logging.Level;
029:        import java.util.logging.Logger;
030:
031:        import javax.servlet.jsp.JspException;
032:        import javax.servlet.jsp.JspWriter;
033:        import javax.servlet.jsp.tagext.BodyContent;
034:        import javax.servlet.jsp.tagext.BodyTagSupport;
035:
036:        import com.sun.portal.log.common.PortalLogger;
037:
038:        /**
039:         * MsgFmtTag performs formatting of message which is 
040:         * equivalent to MessageFormat class in java
041:         * This class allows the arguments to be the JSP tag and
042:         * they can be evaluated independently. The body of the 
043:         * tag should be embedded in the MessageFragment Tag. each 
044:         * fragment tag has unique id. The sequence of the format 
045:         * is defined in a resource bundle referred in catalog 
046:         * and key attribute. It can be used to reorder firstname, lastname
047:         * in different locales
048:         * Any messages/tags that are not embedded in Fragment tag will
049:         * be ignored. 
050:         * @author senthils
051:         */
052:        public class MsgFmtTag extends BodyTagSupport {
053:
054:            private static Logger logger = PortalLogger
055:                    .getLogger(MsgFmtTag.class);
056:
057:            /**
058:             * Initialization of catalog property.
059:             */
060:            private java.lang.String catalog;
061:
062:            /**
063:             * Initialization of key property.
064:             */
065:            private java.lang.String key;
066:
067:            /** Creates a new instance of MsgFmtTag */
068:            public MsgFmtTag() {
069:                super ();
070:            }
071:
072:            /**
073:             * This method is called when the JSP engine encounters the start tag,
074:             * after the attributes are processed.
075:             * Scripting variables (if any) have their values set here.
076:             * @return EVAL_BODY_BUFFERED if the JSP engine should evaluate the tag body, otherwise return SKIP_BODY.
077:             * This method is automatically generated. Do not modify this method.
078:             * Instead, modify the methods that this method calls.
079:             */
080:
081:            public int doStartTag() throws JspException {
082:                fragments = new HashMap();
083:                return EVAL_BODY_BUFFERED;
084:            }
085:
086:            /**
087:             * This method is called after the JSP engine finished processing the tag.
088:             * @return EVAL_PAGE if the JSP engine should continue evaluating the JSP page, otherwise return SKIP_PAGE.
089:             * This method is automatically generated. Do not modify this method.
090:             * Instead, modify the methods that this method calls.
091:             */
092:            public int doEndTag() throws JspException, JspException {
093:                return EVAL_PAGE;
094:            }
095:
096:            /**
097:             * This method is called after the JSP engine processes the body content of the tag.
098:             * @return EVAL_BODY_AGAIN if the JSP engine should evaluate the tag body again, otherwise return SKIP_BODY.
099:             * This method is automatically generated. Do not modify this method.
100:             * Instead, modify the methods that this method calls.
101:             */
102:            public int doAfterBody() throws JspException {
103:                try {
104:                    BodyContent bodyContent = getBodyContent();
105:                    JspWriter out = bodyContent.getEnclosingWriter();
106:                    writeTagBodyContent(out, bodyContent);
107:                } catch (Exception ex) {
108:                    handleBodyContentException(ex);
109:                }
110:                return SKIP_BODY;
111:            }
112:
113:            /**
114:             * Setter for the catalog attribute.
115:             */
116:            public void setCatalog(java.lang.String value) {
117:                this .catalog = value;
118:            }
119:
120:            /**
121:             * Setter for the key attribute.
122:             */
123:            public void setKey(java.lang.String value) {
124:                this .key = value;
125:            }
126:
127:            public void addFragment(String id, String message) {
128:                fragments.put(id, message);
129:            }
130:
131:            private void writeTagBodyContent(JspWriter out,
132:                    BodyContent bodyContent) throws IOException {
133:                rb = (Catalog) pageContext.getAttribute(catalog);
134:                String token = rb.getMsg(key);
135:                String[] tokens = token.split(",");
136:                for (int i = 0; i < tokens.length; i++) {
137:                    String result = null;
138:                    result = (String) fragments.get(tokens[i]);
139:                    if (result != null)
140:                        out.println(result);
141:                }
142:                bodyContent.clearBody();
143:            }
144:
145:            private void handleBodyContentException(Exception ex)
146:                    throws JspException {
147:                // Since the doAfterBody method is guarded, place exception handing code here.
148:                throw new JspException("error in MsgFmtTag: " + ex);
149:            }
150:
151:            public void release() {
152:                super .release();
153:                rb = null;
154:                fragments = null;
155:            }
156:
157:            Map fragments = null;
158:            Catalog rb = null;
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.