Source Code Cross Referenced for CSViewBeanBase.java in  » Portal » Open-Portal » com » sun » portal » search » admin » 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.search.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:
006:        package com.sun.portal.search.admin;
007:
008:        import javax.servlet.http.HttpServletRequest;
009:        import javax.servlet.http.HttpServletResponse;
010:        import java.io.PrintWriter;
011:        import java.util.*;
012:        import java.util.logging.Logger;
013:        import java.util.logging.Level;
014:        import java.text.MessageFormat;
015:        import java.io.IOException;
016:
017:        import com.iplanet.jato.view.View;
018:        import com.iplanet.jato.view.html.StaticTextField;
019:        import com.iplanet.jato.view.ViewBean;
020:        import com.iplanet.jato.view.ViewBeanBase;
021:        import com.iplanet.jato.view.event.*;
022:        import com.iplanet.jato.ViewBeanManager;
023:        import com.iplanet.am.console.base.model.AMModelBase;
024:        import com.iplanet.am.console.base.model.AMModel;
025:        import com.iplanet.am.console.base.model.AMI18NUtils;
026:        import com.iplanet.am.console.base.AMViewBeanBase;
027:        import com.iplanet.am.util.BrowserEncoding;
028:        import com.sun.portal.search.admin.resources.SearchResource;
029:        import com.sun.portal.log.common.PortalLogger;
030:        import com.iplanet.am.console.components.view.html.MessageBox;
031:
032:        /**
033:         * iPS admin console view bean: TODO
034:         */
035:        public class CSViewBeanBase extends AMViewBeanBase implements 
036:                CompassAdminConstants {
037:            public static final String HEADER_VIEW = "HeaderView";
038:            public static final String CHILD_MSGBOX = "MessageBox";
039:            public static final String CN_REQUIRED = "NameRequired";
040:            private AMModelBase ammodel = null;
041:            protected java.util.Locale userLocale = null;
042:            protected String errorMessage = null;
043:            protected String warningMessage = null;
044:            protected String infoMessage = null;
045:            protected String questionMessage = null;
046:
047:            // Create a logger for this class
048:            private static Logger debugLogger = PortalLogger
049:                    .getLogger(CSViewBeanBase.class);
050:
051:            /**
052:             * constructor
053:             *
054:             * @param PageName  of this view bean
055:             * @param displayURL  default display URL
056:             */
057:            public CSViewBeanBase(String page_name) {
058:                super (page_name);
059:                super .registerChildren();
060:                registerChild(HEADER_VIEW, HeaderView.class);
061:                registerChild(CHILD_MSGBOX, MessageBox.class);
062:                registerChild(CN_REQUIRED, StaticTextField.class);
063:
064:            }
065:
066:            /**
067:             * create child component
068:             *
069:             * @param name of component
070:             * @return child component
071:             */
072:            protected View createChild(String name) {
073:                AMModel model = getAMModel();
074:                if (name.equals(HEADER_VIEW)) {
075:                    return new HeaderView(this , HEADER_VIEW);
076:                } else if (name.equals(CHILD_MSGBOX)) {
077:                    return new MessageBox(this , CHILD_MSGBOX, "");
078:                } else if (name.equals(CN_REQUIRED)) {
079:                    return new StaticTextField(this , CN_REQUIRED, "");
080:                } else {
081:                    try {
082:                        return super .createChild(name);
083:                    } catch (Exception e) {
084:                        return null;
085:                    }
086:                }
087:            }
088:
089:            public void setMessageBoxTitle(String title) {
090:                MessageBox child = (MessageBox) getChild(this .CHILD_MSGBOX);
091:                child.setTitle(title);
092:            }
093:
094:            public void addMessageBoxButton(String name, String url) {
095:                MessageBox child = (MessageBox) getChild(this .CHILD_MSGBOX);
096:                child.addButton(name, url);
097:            }
098:
099:            public boolean beginMessageBoxDisplay(ChildDisplayEvent event) {
100:                debugLogger.log(Level.FINER, "PSSH_CSPSA0019", CHILD_MSGBOX);
101:                MessageBox child = (MessageBox) getChild(this .CHILD_MSGBOX);
102:                boolean isVisible = false;
103:                if (errorMessage != null) {
104:                    child.setMessage(errorMessage);
105:                    isVisible = true;
106:                    child.setType(MessageBox.TYPE_ERROR);
107:                } else if (warningMessage != null) {
108:                    child.setMessage(warningMessage);
109:                    isVisible = true;
110:                    child.setType(MessageBox.TYPE_WARNING);
111:                } else if (infoMessage != null) {
112:                    child.setMessage(infoMessage);
113:                    isVisible = true;
114:                    child.setType(MessageBox.TYPE_INFORMATION);
115:                } else if (questionMessage != null) {
116:                    child.setMessage(questionMessage);
117:                    isVisible = true;
118:                    child.setType(MessageBox.TYPE_QUESTION);
119:                }
120:                child.setEnabled(isVisible);
121:                return isVisible;
122:            }
123:
124:            protected String getLocalizedString(String key) {
125:                return SearchResource.geti18nString(key, getUserLocale());
126:            }
127:
128:            protected String getLocalizedString(String key,
129:                    boolean returnKeyIfNotFound) {
130:                return SearchResource
131:                        .geti18nString(key, getUserLocale(), false);
132:            }
133:
134:            protected String[] getLocalizedStringArray(String key, String sep) {
135:                return SearchResource.geti18nArray(key, sep, getUserLocale());
136:            }
137:
138:            protected String getLocalizedMessageFormat(String key, String arg1) {
139:                String[] args = { arg1 };
140:                return getLocalizedMessageFormat(key, args);
141:            }
142:
143:            protected String getLocalizedMessageFormat(String key, String arg1,
144:                    String arg2) {
145:                String[] args = { arg1, arg2 };
146:                return getLocalizedMessageFormat(key, args);
147:            }
148:
149:            protected String getLocalizedMessageFormat(String key, String arg1,
150:                    String arg2, String arg3) {
151:                String[] args = { arg1, arg2, arg3 };
152:                return getLocalizedMessageFormat(key, args);
153:            }
154:
155:            protected String getLocalizedMessageFormat(String key,
156:                    Object[] arguments) {
157:                MessageFormat msgFormat = new MessageFormat("");
158:                String pattern = getLocalizedString(key);
159:                msgFormat.applyPattern(pattern);
160:                return msgFormat.format(arguments);
161:            }
162:
163:            private AMModel getAMModel() {
164:                if (ammodel == null) {
165:                    HttpServletRequest req = getRequestContext().getRequest();
166:                    HttpServletResponse res = getRequestContext().getResponse();
167:                    ammodel = new AMModelBase(req,
168:                            CompassAdminConstants.RESOURCE_BUNDLE_FILE);
169:                }
170:                return ammodel;
171:            }
172:
173:            protected Locale getUserLocale() {
174:                if (userLocale == null) {
175:                    AMModel model = getAMModel();
176:                    if (model != null) {
177:                        userLocale = model.getUserLocale();
178:                    } else {
179:                        userLocale = Locale.getDefault();
180:                    }
181:                }
182:                return userLocale;
183:            }
184:
185:            /**
186:             * Must be called in BeginDisplay of each viewbean
187:             */
188:            protected void setPageEncoding() {
189:                HttpServletRequest req = getRequestContext().getRequest();
190:                HttpServletResponse res = getRequestContext().getResponse();
191:                AMModel model = getAMModel();
192:                String lstr = getLangCountry(model);
193:                debugLogger.log(Level.FINER, "PSSH_CSPSA0020", lstr);
194:                Locale locale = model.getUserLocale();
195:                debugLogger.log(Level.FINER, "PSSH_CSPSA0021", locale
196:                        .toString());
197:
198:                String agentType = model.getClientType();
199:                String contentType = AMI18NUtils.getContentType(agentType);
200:                String charset = AMI18NUtils.getCharset(agentType, locale);
201:                debugLogger.log(Level.FINER, "PSSH_CSPSA0022", new String[] {
202:                        contentType, charset });
203:                res.setContentType(contentType + ";charset=" + charset);
204:
205:                try {
206:                    res.getWriter();
207:                } catch (IOException ex) {
208:                    /* Problem in handling charset Ignore it*/
209:                    res.setContentType(contentType);
210:                }
211:                String jCharset = BrowserEncoding.mapHttp2JavaCharset(charset);
212:                setDisplayFieldValue(PAGE_ENCODING, jCharset);
213:                setDisplayFieldValue(HELP_DOC_URL,
214:                        getLocalizedString("help.docurl"));
215:            }
216:
217:            private String getLangCountry(AMModel model) {
218:                Locale locale = model.getUserLocale();
219:                String lstr;
220:                String lang = locale.getLanguage();
221:                String country = locale.getCountry();
222:
223:                if ((country == null) || (country.length() == 0)) {
224:                    lstr = lang;
225:                } else {
226:                    lstr = lang + "_" + country;
227:                }
228:
229:                return lstr;
230:            }
231:
232:            /*
233:            protected String getCharset(AMModel model) {
234:            Locale locale = model.getUserLocale();
235:            String agentType = model.getClientType();
236:            String charset =model.getCharset(agentType,locale);
237:            String jCharset = BrowserEncoding.mapHttp2JavaCharset (charset);
238:            return jCharset;
239:            }
240:             */
241:
242:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.