Source Code Cross Referenced for SchemaEditorViewBean.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 java.lang.*;
009:        import java.io.IOException;
010:
011:        import javax.servlet.*;
012:        import javax.servlet.http.*;
013:
014:        import com.iplanet.jato.RequestContext;
015:        import com.iplanet.jato.RequestHandler;
016:        import com.iplanet.jato.util.*;
017:
018:        import com.iplanet.jato.view.event.DisplayEvent;
019:        import com.iplanet.jato.view.event.ChildDisplayEvent;
020:        import com.iplanet.jato.view.event.RequestInvocationEvent;
021:
022:        import com.iplanet.jato.view.html.OptionList;
023:        import com.iplanet.jato.view.html.Option;
024:        import com.iplanet.jato.view.html.CheckBox;
025:        import com.iplanet.jato.view.html.TextField;
026:        import com.iplanet.jato.view.html.ListBox;
027:        import com.iplanet.jato.view.html.StaticTextField;
028:        import com.iplanet.jato.view.html.HiddenField;
029:        import com.iplanet.jato.view.html.ComboBox;
030:        import com.iplanet.jato.view.html.Button;
031:
032:        import com.iplanet.jato.view.View;
033:        import com.iplanet.jato.view.ViewBean;
034:        import com.iplanet.jato.view.ViewBeanBase;
035:
036:        import com.iplanet.jato.ViewBeanManager;
037:
038:        import com.iplanet.jato.model.ModelControlException;
039:
040:        import com.iplanet.am.console.components.view.html.IPlanetButton;
041:        import com.iplanet.am.console.components.view.html.MessageBox;
042:
043:        import com.sun.portal.search.admin.model.SchemaModel;
044:
045:        /**
046:         *  Schema Editor Wizard for editing database schema
047:         *  It extends from <code>CSViewBeanBase</code>.
048:         */
049:
050:        public class SchemaEditorViewBean extends CSViewBeanBase implements 
051:                RequestHandler {
052:
053:            // The "logical" name for this page.
054:            public static final String PAGE_NAME = "SchemaEditor";
055:            public static final String DEFAULT_DISPLAY_URL = "/ps/searchadmin/SchemaEditor.jsp";
056:
057:            // String constants for child field names.  This is simply good coding practice
058:            // to minimize use of string literals.
059:            //public static final String LST_SCHEMA = "schemaLst";
060:            public static final String FLD_NAME = "name";
061:            public static final String FLD_OLDNAME = "oldname";
062:            public static final String FLD_DESCRIPTION = "description";
063:            public static final String FLD_ALIASES = "aliases";
064:            public static final String FLD_EDITABLE = "editable";
065:            public static final String FLD_INDEXABLE = "indexable";
066:            public static final String FLD_DATATYPE = "datatype";
067:            public static final String FLD_GETVAL = "getval";
068:            public static final String FLD_MULTIPLIER = "multiplier";
069:            //public static final String BTN_ADD   = "add";
070:            public static final String BTN_SUBMIT = "Submit";
071:            public static final String BTN_CANCEL = "Cancel";
072:            //public static final String BTN_DELETE   = "delete";
073:            public static final String CHILD_ERROR_MSG_BOX = "errorMsgBox";
074:            public static final String BTN_CHANGEINDEXABLE = "BTNChangeIndexable";
075:
076:            public static final String UPDATE_ERROR = "updateError";
077:            public static final String INVALID_NAME = "invalidname";
078:            // Model
079:            private SchemaModel model = null;
080:
081:            /*
082:             * Default constructor
083:             *
084:             */
085:            public SchemaEditorViewBean() {
086:                super (PAGE_NAME);
087:                setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
088:                registerChildren();
089:            }
090:
091:            /**
092:             * Child methods
093:             */
094:            protected void registerChildren() {
095:                // Add an entry for each child. Note, the children are not instantiated
096:                // at this time. Instead, child instantiation is handled in a lazy fashion.
097:
098:                //registerChild(LST_SCHEMA,ListBox.class);
099:                registerChild(FLD_NAME, TextField.class);
100:                registerChild(FLD_OLDNAME, HiddenField.class);
101:                registerChild(FLD_DESCRIPTION, TextField.class);
102:                registerChild(FLD_ALIASES, TextField.class);
103:                registerChild(FLD_MULTIPLIER, TextField.class);
104:                registerChild(FLD_EDITABLE, CheckBox.class);
105:                registerChild(FLD_INDEXABLE, CheckBox.class);
106:                registerChild(FLD_DATATYPE, ComboBox.class);
107:                //registerChild(FLD_GETVAL,HiddenField.class);
108:                //registerChild(BTN_ADD,IPlanetButton.class);
109:                registerChild(BTN_SUBMIT, IPlanetButton.class);
110:                registerChild(BTN_CANCEL, IPlanetButton.class);
111:                registerChild(BTN_CHANGEINDEXABLE, Button.class);
112:                //registerChild(UPDATE_ERROR,StaticTextField.class);
113:                //registerChild(INVALID_NAME,StaticTextField.class);
114:                registerChild(CHILD_ERROR_MSG_BOX, MessageBox.class);
115:            }
116:
117:            protected View createChild(String name) {
118:                // Create HeaderView Child
119:                View child = super .createChild(name);
120:                if (child != null) {
121:                    return child;
122:
123:                } else if (name.equals(BTN_SUBMIT)) {
124:                    return new IPlanetButton(this , BTN_SUBMIT, "");
125:
126:                } else if (name.equals(BTN_CANCEL)) {
127:                    return new IPlanetButton(this , BTN_CANCEL, "");
128:                } else if (name.equals(BTN_CHANGEINDEXABLE)) {
129:                    return new Button(this , BTN_CHANGEINDEXABLE, "");
130:
131:                } else if (name.equals(FLD_NAME)) {
132:                    return new TextField(this , FLD_NAME, "");
133:
134:                } else if (name.equals(FLD_OLDNAME)) {
135:                    return new HiddenField(this , FLD_OLDNAME, "");
136:
137:                } else if (name.equals(FLD_DESCRIPTION)) {
138:                    return new TextField(this , FLD_DESCRIPTION, "");
139:
140:                } else if (name.equals(FLD_ALIASES)) {
141:                    return new TextField(this , FLD_ALIASES, "");
142:                } else if (name.equals(FLD_MULTIPLIER)) {
143:                    return new TextField(this , FLD_MULTIPLIER, "");
144:
145:                } else if (name.equals(FLD_EDITABLE)) {
146:                    return new CheckBox(this , FLD_EDITABLE, "true", "false",
147:                            true);
148:
149:                } else if (name.equals(FLD_INDEXABLE)) {
150:                    return new CheckBox(this , FLD_INDEXABLE, "true", "false",
151:                            true);
152:                } else if (name.equals(FLD_DATATYPE)) {
153:                    ComboBox datatype = new ComboBox(this , FLD_DATATYPE,
154:                            "string");
155:                    datatype.setOptions(new OptionList(SchemaModel.DATA_TYPES,
156:                            SchemaModel.DATA_TYPES));
157:                    return datatype;
158:                } else if (name.equals(CHILD_ERROR_MSG_BOX)) {
159:                    return new MessageBox(this , CHILD_ERROR_MSG_BOX, "");
160:                } else
161:                    throw new IllegalArgumentException("Invalid child name \""
162:                            + name + "\"");
163:            }
164:
165:            public boolean beginMultiplierSectionDisplay(ChildDisplayEvent event) {
166:                return getDisplayFieldBooleanValue(FLD_INDEXABLE);
167:            }
168:
169:            /*
170:             * Begin displaying page. we set the required information
171:             * The schema editor will be displayed. The field list, field name, field description
172:             * isEditable, isIndexable values are retrieved from the model in initContent and
173:             * set the individual display fields in the view bean
174:             * @param event   display event
175:             * @throws ModelControlException  if problem access value of component
176:             **/
177:            public void beginDisplay(DisplayEvent event)
178:                    throws ModelControlException {
179:                setPageEncoding();
180:                setDisplayFieldValue(BTN_SUBMIT,
181:                        getLocalizedString("submit.text"));
182:                setDisplayFieldValue(BTN_CANCEL,
183:                        getLocalizedString("cancel.text"));
184:
185:                if (getPageSessionAttribute("retrieved") != null) {
186:                    return;
187:                }
188:
189:                String encodedName = this .getRequestContext().getRequest()
190:                        .getParameter("SchemaName");
191:                if (encodedName != null) {
192:                    String schemaName = "";
193:                    try {
194:
195:                        schemaName = new String(Encoder
196:                                .decodeBase64(encodedName), "UTF-8");
197:                    } catch (Exception e) {
198:                        schemaName = encodedName;
199:                    }
200:                    setDisplayFieldValue(FLD_OLDNAME, schemaName);
201:                    model = getModel(schemaName);
202:                }
203:                if (model != null) {
204:                    // get field name
205:                    setDisplayFieldValue(FLD_NAME, model.getName());
206:
207:                    // get field description
208:                    setDisplayFieldValue(FLD_DESCRIPTION, model
209:                            .getDescription());
210:
211:                    // get field aliases
212:                    setDisplayFieldValue(FLD_ALIASES, model.getAliases());
213:
214:                    // get field multipler
215:                    setDisplayFieldValue(FLD_MULTIPLIER, model.getMultiplier());
216:
217:                    // get isEditable
218:                    CheckBox c1 = (CheckBox) getChild(FLD_EDITABLE);
219:                    c1.setChecked(model.getEditable());
220:
221:                    // get isIndexable
222:                    CheckBox c2 = (CheckBox) getChild(FLD_INDEXABLE);
223:                    c2.setChecked(model.getIndexable());
224:
225:                    setDisplayFieldValue(FLD_DATATYPE, model.getDataType());
226:
227:                }
228:                setPageSessionAttribute("retrieved", "true");
229:            }
230:
231:            public boolean beginErrorsDisplay(ChildDisplayEvent event) {
232:                String err1 = (String) getDisplayFieldValue(UPDATE_ERROR);
233:                String err2 = (String) getDisplayFieldValue(INVALID_NAME);
234:
235:                if (err1.equals("") && err2.equals("")) {
236:                    return false;
237:                } else {
238:                    return true;
239:                }
240:            }
241:
242:            private void forwardToSchemaList() {
243:                try {
244:                    HttpServletResponse response = getRequestContext()
245:                            .getResponse();
246:                    response.sendRedirect("SchemaList");
247:                } catch (IOException e) {
248:                    //TOFIX: handle this
249:                }
250:            }
251:
252:            public void handleBTNChangeIndexableRequest(
253:                    RequestInvocationEvent event) {
254:                forwardTo();
255:            }
256:
257:            /*
258:             * handles invocation of Update Button
259:             *
260:             * @param event   request invocation event
261:             */
262:            public void handleSubmitRequest(RequestInvocationEvent event) {
263:
264:                model = getModel((String) getDisplayFieldStringValue(FLD_OLDNAME));
265:                setSchemaModelValues(model);
266:                boolean success = model.doUpdate();
267:
268:                if (success) {
269:                    forwardToSchemaList();
270:                } else {
271:                    MessageBox errorMsgBox = (MessageBox) getChild(CHILD_ERROR_MSG_BOX);
272:                    String errMsg = model.getErrorMessage();
273:                    if (errMsg != null) {
274:                        errorMsgBox.setType(MessageBox.TYPE_ERROR);
275:                        errorMsgBox.setMessage(getLocalizedString(errMsg));
276:                        errorMsgBox.setEnabled(true);
277:                    } else {
278:                        errorMsgBox.setEnabled(false);
279:                    }
280:                    forwardTo();
281:                }
282:            }
283:
284:            public void handleCancelRequest(RequestInvocationEvent event) {
285:                forwardToSchemaList();
286:            }
287:
288:            protected SchemaModel getModel(String name) {
289:                if (model == null) {
290:                    model = new SchemaModel(name);
291:                }
292:                return model;
293:            }
294:
295:            public void setSchemaModelValues(SchemaModel model) {
296:                model.setName((String) getDisplayFieldValue(FLD_NAME));
297:                model
298:                        .setDescription((String) getDisplayFieldValue(FLD_DESCRIPTION));
299:                model.setAliases((String) getDisplayFieldValue(FLD_ALIASES));
300:                model
301:                        .setMultiplier((String) getDisplayFieldValue(FLD_MULTIPLIER));
302:                model.setEditable(getDisplayFieldBooleanValue(FLD_EDITABLE));
303:                model.setIndexable(getDisplayFieldBooleanValue(FLD_INDEXABLE));
304:                model.setDataType(getDisplayFieldStringValue(FLD_DATATYPE));
305:            }
306:
307:            public boolean validateSchema() {
308:                String name = (String) getDisplayFieldValue(FLD_NAME);
309:                if (name.equals(""))
310:                    return false;
311:
312:                for (int i = 0; i < name.length(); i++) {
313:                    char c = name.charAt(i);
314:                    if ((!Character.isLetterOrDigit(c)) && (c != '.')
315:                            && (c != '-') && (c != '_')) {
316:                        return false;
317:                    }
318:                }
319:
320:                return true;
321:            }
322:
323:            public void checkReqType() {
324:                RequestContext rc = getRequestContext();
325:                HttpServletRequest req = rc.getRequest();
326:                if (req.getParameter("SchemaEditor.schemaLst") != null) {
327:                    String sch = req.getParameter("SchemaEditor.schemaLst");
328:                    model.setName(sch);
329:                } else {
330:                    model.initializeValues();
331:                }
332:            }
333:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.