Source Code Cross Referenced for NTTView.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:        /*
007:         * NTTView.java
008:         *
009:         * Created on January 24, 2002, 12:42 AM
010:         */
011:
012:        package com.sun.portal.search.admin;
013:
014:        import java.io.*;
015:        import java.lang.reflect.*;
016:        import java.util.*;
017:        import java.util.logging.Logger;
018:        import java.util.logging.Level;
019:        import java.net.*;
020:
021:        import javax.servlet.*;
022:        import javax.servlet.http.*;
023:        import javax.servlet.jsp.tagext.Tag;
024:
025:        import com.iplanet.jato.*;
026:        import com.iplanet.jato.model.*;
027:        import com.iplanet.jato.util.*;
028:        import com.iplanet.jato.view.*;
029:        import com.iplanet.jato.view.event.*;
030:        import com.iplanet.jato.view.html.*;
031:        import com.iplanet.jato.taglib.tree.html.TreeNodeHandleTag;
032:
033:        import com.sun.portal.search.util.SearchConfig;
034:        import com.sun.portal.search.rdm.RDMClassification;
035:        import com.sun.portal.search.rdm.RDMTaxonomy;
036:        import com.sun.portal.search.admin.model.TaxonomyTreeModel;
037:        import com.sun.portal.log.common.PortalLogger;
038:
039:        import com.iplanet.am.console.components.view.html.IPlanetButton;
040:
041:        /**
042:         *
043:         */
044:        public class NTTView extends RequestHandlingTreeViewBase {
045:            //////////////////////////////////////
046:            // Class variables
047:            //////////////////////////////////////
048:            // children handles
049:            public static final String CHILD_NAME = "name";
050:            public static final String CHILD_HREF = "Href1";
051:            public static final String CHILD_HANDLE_TARGET_PAGE = "handleTargetPage";
052:            public static final String CHILD_HREF_ADD_CHILD = "hrefAddChild";
053:            public static final String CHILD_HREF_ADD_SIBLING = "hrefAddSibling";
054:            public static final String CHILD_HREF_UPDATE = "hrefUpdate";
055:            public static final String CHILD_HREF_DELETE = "hrefDelete";
056:            public static final String CHILD_CATEGORY_EDITOR = "NCE";
057:
058:            //miscelaneous
059:            public static final String NODE_ID = "nodeId";
060:
061:            //////////////////////////////////////
062:            // Instance variables
063:            //////////////////////////////////////
064:            public int currentPage = 1;
065:            public int nbPages = 1;
066:            public int nbDisplayable = -1;
067:            public int maxNbNodesDisplayed;
068:            public int displayableNodeCounter = 0;
069:            // index of the page to display
070:            private int displayedPage = -1;
071:            private int editedCategory = -1;
072:
073:            // Create a Logger for this class
074:            private static Logger debugLogger = PortalLogger
075:                    .getLogger(NTTView.class);
076:
077:            /** Creates new NTTView */
078:            public NTTView(View parent, String name)
079:                    throws ModelControlException {
080:                super (parent, name);
081:                try {
082:                    setPrimaryModel(getTaxonomyTreeModel());
083:                    registerChildren();
084:                } catch (Exception e) {
085:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
086:                            .getMessage());
087:                    throw new ModelControlException(e.getMessage());
088:                }
089:            }
090:
091:            /**
092:             *
093:             *
094:             */
095:            protected void registerChildren() {
096:                try {
097:                    registerChild(CHILD_NAME, StaticTextField.class);
098:                    registerChild(CHILD_HREF, HREF.class);
099:                    // in case we use images link for the editing commandes
100:                    registerChild(CHILD_HANDLE_TARGET_PAGE,
101:                            StaticTextField.class);
102:                    registerChild(CHILD_HREF_ADD_CHILD, HREF.class);
103:                    registerChild(CHILD_HREF_ADD_SIBLING, HREF.class);
104:                    registerChild(CHILD_HREF_UPDATE, HREF.class);
105:                    registerChild(CHILD_HREF_DELETE, HREF.class);
106:                    registerChild(CHILD_CATEGORY_EDITOR, NCEView.class);
107:                } catch (Exception e) {
108:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
109:                            .getMessage());
110:                }
111:            }
112:
113:            /**
114:             *
115:             *
116:             */
117:            protected View createChild(String name) {
118:                try {
119:                    View child = null;
120:                    // CHILD_NAME
121:                    if (name.equals(CHILD_NAME)) {
122:                        child = new StaticTextField(this ,
123:                                getTaxonomyTreeModel(), CHILD_NAME,
124:                                TaxonomyTreeModel.FIELD_NAME, "", null);
125:                        return child;
126:                    }
127:                    // CHILD_HREF
128:                    if (name.equals(CHILD_HREF)) {
129:                        // build the URL
130:                        child = new HREF(this , CHILD_HREF, "");
131:                        return child;
132:                    }
133:                    // CHILD_HANDLE_TARGET_PAGE
134:                    if (name.equals(CHILD_HANDLE_TARGET_PAGE)) {
135:                        // build the URL
136:                        child = new HREF(this , CHILD_HANDLE_TARGET_PAGE, "");
137:                        return child;
138:                    }
139:                    // CHILD_HREF_ADD_CHILD
140:                    if (name.equals(CHILD_HREF_ADD_CHILD)) {
141:                        // build the URL
142:                        child = new HREF(this , CHILD_HREF_ADD_CHILD, "");
143:                        return child;
144:                    }
145:                    // CHILD_HREF_ADD_SIBLING
146:                    if (name.equals(CHILD_HREF_ADD_SIBLING)) {
147:                        // build the URL
148:                        child = new HREF(this , CHILD_HREF_ADD_SIBLING, "");
149:                        return child;
150:                    }
151:                    // CHILD_HREF_UPDATE
152:                    if (name.equals(CHILD_HREF_UPDATE)) {
153:                        // build the URL
154:                        child = new HREF(this , CHILD_HREF_UPDATE, "");
155:                        return child;
156:                    }
157:                    // CHILD_HREF_DELETE
158:                    if (name.equals(CHILD_HREF_DELETE)) {
159:                        // build the URL
160:                        child = new HREF(this , CHILD_HREF_DELETE, "");
161:                        return child;
162:                    }
163:                    // CHILD_CATEGORY_EDITOR
164:                    if (name.equals(CHILD_CATEGORY_EDITOR)) {
165:                        // build the URL
166:                        child = new NCEView(this , CHILD_CATEGORY_EDITOR);
167:                        return child;
168:                    }
169:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0002", name);
170:
171:                    if (name != null) {
172:                        throw new IllegalArgumentException(
173:                                "Invalid child name [" + name + "]");
174:                    } else {
175:                        throw new IllegalArgumentException(
176:                                "Invalid child name [<NULL>]");
177:                    }
178:                } catch (Exception e) {
179:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
180:                            .getMessage());
181:
182:                    if (name != null) {
183:                        throw new IllegalArgumentException(
184:                                "Invalid child name [" + name + "]");
185:                    } else {
186:                        throw new IllegalArgumentException(
187:                                "Invalid child name [<NULL>]");
188:                    }
189:                }
190:            }
191:
192:            /* 
193:             *
194:             */
195:            public void beginNameDisplay(ChildDisplayEvent event) {
196:                setDisplayFieldValue(CHILD_NAME, "dummy name");
197:            }
198:
199:            /**
200:             *
201:             *
202:             */
203:            public void beginDisplay(DisplayEvent event) {
204:                NTEViewBean pvb = (NTEViewBean) getParentViewBean();
205:                try {
206:                    nbPages = pvb.nbPages;
207:                    nbDisplayable = pvb.nbDisplayable;
208:                    maxNbNodesDisplayed = pvb.maxNbNodesDisplayed;
209:
210:                    RequestContext rc = getRequestContext();
211:                    HttpServletRequest req = rc.getRequest();
212:                    String currentPageStr = (String) req
213:                            .getParameter(NTEViewBean.DISPLAY_PAGE);
214:                    if (currentPageStr != null) {
215:                        currentPage = (new Integer(currentPageStr)).intValue();
216:                    } else {
217:                        Integer currentPageInt = (Integer) pvb
218:                                .getPageSessionAttribute(NTEViewBean.DISPLAY_PAGE);
219:                        currentPage = (currentPageInt != null) ? currentPageInt
220:                                .intValue() : 1;
221:                    }
222:                    String editedCategoryStr;
223:                    // pick up selected id from query string
224:                    editedCategoryStr = (String) req
225:                            .getParameter(NTEViewBean.TAX_ACTION_EDIT);
226:                    if (editedCategoryStr != null) {
227:                        try {
228:                            editedCategory = Integer
229:                                    .parseInt(editedCategoryStr);
230:                        } catch (NumberFormatException nfe) {
231:                            debugLogger.log(Level.INFO, "PSSH_CSPSA0062",
232:                                    editedCategoryStr);
233:                            editedCategory = -1;
234:                        }
235:                    }
236:                    // Ensure the primary model is non-null; if null, it would cause
237:                    // havoc with the various methods dependent on the primary model
238:                    if (getTaxonomyTreeModel() == null) {
239:                        throw new ModelControlException("Primary model is null");
240:                    }
241:                    super .beginDisplay(event);
242:                } catch (Exception e) {
243:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0061", new String[] {
244:                            event.toString(), e.getMessage() });
245:                }
246:            }
247:
248:            /*
249:             * returns true if current node is root
250:             */
251:            public boolean beginIsRootNodeDisplay(ChildDisplayEvent event) {
252:                boolean b = false;
253:                try {
254:                    RDMClassification currentNode = (RDMClassification) getTaxonomyTreeModel()
255:                            .getCurrentNode();
256:                    if (currentNode.getParentId() == null) {
257:                        b = true;
258:                    } else {
259:                        b = false;
260:                    }
261:                    return b;
262:                } catch (Exception e) {
263:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
264:                            .getMessage());
265:                    return b;
266:                }
267:            }
268:
269:            /*
270:             * returns false if current node is NOT root
271:             */
272:            public boolean beginIsNotRootNodeDisplay(ChildDisplayEvent event) {
273:                boolean b = !beginIsRootNodeDisplay(event);
274:                return b;
275:            }
276:
277:            /**
278:             *
279:             */
280:            public boolean beginHrefDisplay(ChildDisplayEvent event, HREF href,
281:                    String action) {
282:                try {
283:                    RDMClassification currentNode = (RDMClassification) getTaxonomyTreeModel()
284:                            .getCurrentNode();
285:                    /*
286:                    String nodeId = (String)getTaxonomyTreeModel().getNodeID();
287:                    String nodeName = TaxonomyTreeModel.lastNode((String)getTaxonomyTreeModel().getNodeName());
288:                     */
289:                    href.addExtraValue(NTEViewBean.DISPLAY_PAGE, String
290:                            .valueOf(currentPage));
291:                    href.addExtraValue(NTEViewBean.TAX_ACTION_EDIT, String
292:                            .valueOf(displayableNodeCounter));
293:
294:                    return true;
295:                } catch (Exception e) {
296:
297:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0066", new String[] {
298:                            event.toString(), href.toString(), action,
299:                            e.getMessage() });
300:                    return false;
301:                }
302:            }
303:
304:            /* 
305:             * sets the pageNumber as the queryParams for the treeNodeHandle, so as
306:             * to be able to toggle them on/off and still display same target page
307:             */
308:            public boolean beginHandleTargetPageDisplay(DisplayEvent event) {
309:                // the target page value is :
310:                // number of displayable nodes so far / max number of nodes per page
311:                int targetPage = getNodePage();
312:                setDisplayFieldValue(CHILD_HANDLE_TARGET_PAGE, String
313:                        .valueOf(targetPage));
314:                return true;
315:            }
316:
317:            /*
318:             * get the page in which the node is displayed
319:             */
320:            public int getNodePage() {
321:                try {
322:                    int ret = displayableNodeCounter;
323:                    if (ret <= 0) {
324:                        // display all nodes
325:                        return ret = 1;
326:                    }
327:                    return ret;
328:                } catch (Exception e) {
329:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
330:                            .getMessage());
331:                    return 1;
332:                }
333:
334:            }
335:
336:            /*
337:             *
338:             */
339:            public boolean beginDisplayedNodeDisplay(ChildDisplayEvent event) {
340:                boolean ret = false;
341:                try {
342:                    // increase the number of node Displayed. 
343:                    displayableNodeCounter++;
344:
345:                    if (editedCategory != -1) {
346:                        // if in editmode, hide all tree nodes that are note edited
347:                        if (displayableNodeCounter == editedCategory)
348:                            ret = true;
349:                        else
350:                            ret = false;
351:                    } else {
352:                        if (maxNbNodesDisplayed != -1) {
353:                            //if node in the page range display it
354:                            if ((displayableNodeCounter >= currentPage)
355:                                    && (displayableNodeCounter < currentPage
356:                                            + maxNbNodesDisplayed)) {
357:                                ret = true;
358:                            } else {
359:                                ret = false;
360:                            }
361:                        } else {
362:                            ret = true;
363:                        }
364:                    }
365:                } catch (Exception e) {
366:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0061", new String[] {
367:                            event.toString(), e.getMessage() });
368:                }
369:                return ret;
370:            }
371:
372:            /**
373:             *
374:             */
375:            public boolean beginHref1Display(ChildDisplayEvent event) {
376:                try {
377:                    return beginHrefDisplay(event,
378:                            (HREF) getDisplayField(CHILD_HREF),
379:                            NTEViewBean.TAX_ACTION_EDIT);
380:                } catch (Exception e) {
381:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0061", new String[] {
382:                            event.toString(), e.getMessage() });
383:                    return false;
384:                }
385:            }
386:
387:            /*
388:             *
389:             */
390:            public TaxonomyTreeModel getTaxonomyTreeModel() {
391:                NTEViewBean pvb = (NTEViewBean) getParentViewBean();
392:                return pvb.getTaxonomyTreeModel();
393:            }
394:
395:            /**
396:             * method to dynamicaly decide if we include or not the content labelled 
397:             * "CategoryEditorContent"
398:             */
399:            public boolean beginHighlightDisplay(ChildDisplayEvent event) {
400:                try {
401:                    if (displayableNodeCounter == editedCategory) {
402:                        return true;
403:                    } else {
404:                        return false;
405:                    }
406:                } catch (Exception e) {
407:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
408:                            .getMessage());
409:                    return false;
410:                }
411:            }
412:
413:            /* 
414:             * edit mode is displayed if selected id for action 
415:             * and/or if an error occured during the preceeding edition
416:             */
417:            public boolean beginEditModeDisplay(ChildDisplayEvent event) {
418:                return !beginBrowseModeDisplay(event);
419:            }
420:
421:            public boolean beginBrowseModeDisplay(ChildDisplayEvent event) {
422:                NTEViewBean pvb = (NTEViewBean) getParentViewBean();
423:                return pvb.beginBrowseModeDisplay(event);
424:            }
425:
426:            //////////////////////////////////////
427:            // Event handling methods
428:            //////////////////////////////////////
429:
430:            /**
431:             *
432:             */
433:            public void handleHref1Request(RequestInvocationEvent event)
434:                    throws ModelControlException {
435:                try {
436:                    // dertermining the selected node
437:                    RequestContext rc = event.getRequestContext();
438:                    HttpServletRequest req = rc.getRequest();
439:                    String nodePage = (String) req
440:                            .getParameter(NTEViewBean.DISPLAY_PAGE);
441:                    String nodePageQry = (nodePage == null) ? "" : "&"
442:                            + NTEViewBean.DISPLAY_PAGE + "=" + nodePage;
443:                    // refresh the category editor this time should 
444:                    // display the CategoryEditor "jato:content"
445:                    HttpServletResponse resp = rc.getResponse();
446:                    try {
447:                        String editedNodeStr = req
448:                                .getParameter(NTEViewBean.TAX_ACTION_EDIT);
449:                        String editedNodeQry;
450:                        if (editedNodeStr != null) {
451:                            editedNodeQry = "&" + NTEViewBean.TAX_ACTION_EDIT
452:                                    + "=" + editedNodeStr;
453:                        } else {
454:                            editedNodeQry = "";
455:                        }
456:                        resp.sendRedirect(NTEViewBean.PAGE_NAME
457:                                + "?gx_charset=UTF-8&" + editedNodeQry
458:                                + nodePageQry + "&#selected");
459:                    } catch (IOException ioe) {
460:                        debugLogger.log(Level.INFO, "PSSH_CSPSA0010", ioe
461:                                .getMessage());
462:                    }
463:                } catch (Exception e) {
464:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
465:                            .getMessage());
466:                    throw new ModelControlException(
467:                            "failed to handle click on category link "
468:                                    + e.getMessage());
469:                }
470:            }
471:
472:            /**
473:             * for i18n related issue, we can't rely on the treehandle in the URL 
474:             * qurey String (Japanese characters being tranformed in '?').
475:             * this limitation prevents the handle toggleling to work.
476:             * to circumvent this, we need to 
477:             */
478:            protected Object acceptTreeHandleRequest(HttpServletRequest req) {
479:                //TODO
480:                return super .acceptTreeHandleRequest(req);
481:            }
482:
483:            //////////////////////////////////////
484:            // utility
485:            //////////////////////////////////////
486:
487:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.