Source Code Cross Referenced for DiscCatalog.java in  » J2EE » Enhydra-Demos » discRack » presentation » discMgmt » 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 » J2EE » Enhydra Demos » discRack.presentation.discMgmt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Enhydra Java Application Server Project
003:         * 
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         * 
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         * 
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         * 
019:         * Contributor(s):
020:         * 
021:         * $Id: DiscCatalog.java,v 1.1 2006-09-11 12:32:06 sinisa Exp $
022:         */
023:
024:        package discRack.presentation.discMgmt;
025:
026:        import discRack.spec.*;
027:        import discRack.presentation.BasePO;
028:        import discRack.presentation.DiscRackPresentationException;
029:
030:        import com.lutris.appserver.server.httpPresentation.*;
031:        import com.lutris.appserver.server.session.*;
032:        import com.lutris.util.*;
033:        import org.enhydra.xml.xmlc.*;
034:        import org.enhydra.xml.xmlc.html.*;
035:        import org.enhydra.xml.xmlc.XMLObject;
036:        import org.w3c.dom.*;
037:        import org.w3c.dom.html.*;
038:
039:        /**
040:         * This class populates discs and display on the page.
041:         *
042:         */
043:        public class DiscCatalog extends BasePO {
044:
045:            /**
046:             * Superclass method override
047:             */
048:            public boolean loggedInUserRequired() {
049:                return true;
050:            }
051:
052:            /**
053:             * Default event. Just show the page.
054:             *
055:             * @return html document
056:             * @exception HttpPresentationException
057:             */
058:            public XMLObject handleDefault()
059:                    throws DiscRackPresentationException {
060:                // Swap in our real run-time JavaScript to repalce the storyboard JavaScript
061:
062:                DiscCatalogHTML page = (DiscCatalogHTML) myComms.xmlcFactory
063:                        .create(DiscCatalogHTML.class);
064:                HTMLScriptElement script = ((DiscCatalogScriptHTML) myComms.xmlcFactory
065:                        .create(DiscCatalogScriptHTML.class))
066:                        .getElementRealScript();
067:                //        HTMLScriptElement script = new DiscCatalogScriptHTML().getElementRealScript();
068:                XMLCUtil.replaceNode(script, page.getElementDummyScript());
069:
070:                /*
071:                 * Catch Null pointer exception ( we canot make a instances of classes from business layer  when we run discRack_pres )
072:                 * We need  to allow discRack_pres to be functional ,  response
073:                 * will be default HTML page
074:                 */
075:
076:                try {
077:
078:                    Disc[] discList = ((DiscGenerator) DiscGeneratorFactory
079:                            .getDiscGenerator("discRack.business.disc.DiscGeneratorImpl"))
080:                            .findDiscsForPerson(this .getUser());
081:
082:                    try {
083:                        page.setTextOwner(this .getUser().getFirstname() + " "
084:                                + this .getUser().getLastname() + "'s Discs");
085:                    } catch (Exception ex) {
086:                        this .writeDebugMsg("Error getting user info: " + ex);
087:                    }
088:
089:                    String errorMsg = this .getSessionData()
090:                            .getAndClearUserMessage();
091:                    if (null == errorMsg) {
092:                        page.getElementErrorText().getParentNode().removeChild(
093:                                page.getElementErrorText());
094:                    } else {
095:                        page.setTextErrorText(errorMsg);
096:                    }
097:
098:                    // Generate the person's Disc list and create the HTML template references
099:                    HTMLTableRowElement templateRow = page
100:                            .getElementTemplateRow();
101:                    HTMLOptionElement templateOption = page
102:                            .getElementTemplateOption();
103:                    Node discTable = templateRow.getParentNode();
104:                    Node discSelect = templateOption.getParentNode();
105:
106:                    // Remove ids to prevent duplicates 
107:                    templateRow.removeAttribute("id");
108:                    templateOption.removeAttribute("id");
109:
110:                    // Remove id attributes from the cells in the template row
111:                    HTMLElement artistCellTemplate = page.getElementArtist();
112:                    HTMLElement titleCellTemplate = page.getElementTitle();
113:                    HTMLElement genreCellTemplate = page.getElementGenre();
114:                    HTMLElement likeThisDisc = page.getElementLikeThisDisc();
115:
116:                    artistCellTemplate.removeAttribute("id");
117:                    titleCellTemplate.removeAttribute("id");
118:                    genreCellTemplate.removeAttribute("id");
119:                    likeThisDisc.removeAttribute("id");
120:
121:                    // Remove the dummy storyboard text from the prototype HTML
122:                    templateOption.removeChild(templateOption.getFirstChild());
123:
124:                    // Get collection of Discs and loop through collection
125:                    // to add each disc as a row in the table.
126:                    for (int numDiscs = 0; numDiscs < discList.length; numDiscs++) {
127:                        Disc currentDisc = discList[numDiscs];
128:                        // set text of new cells to values from string array
129:                        page.setTextArtist(currentDisc.getArtist());
130:                        page.setTextTitle(currentDisc.getTitle());
131:                        page.setTextGenre(currentDisc.getGenre());
132:
133:                        if (currentDisc.isLiked()) {
134:                            page.setTextLikeThisDisc("Yes");
135:                        } else {
136:                            page.setTextLikeThisDisc("Not");
137:                        }
138:
139:                        // Add a deep clone of the row to the DOM
140:                        Node clonedNode = templateRow.cloneNode(true);
141:                        discTable.appendChild(clonedNode);
142:                        // Alternative way to insert nodes below
143:                        // insertBefore(newNode, oldNode);
144:                        // discTable.insertBefore(clonedNode, templateRow);
145:
146:                        // Now populate the select list
147:                        // This algorithm is obscure because options are not normal 
148:                        //  HTML elements
149:                        // First populate the option value (the disc database ID). 
150:                        //  Then append a text child as the option
151:                        // text, which is what is displayed as the text
152:                        // in each row of the select box
153:                        HTMLOptionElement clonedOption = (HTMLOptionElement) templateOption
154:                                .cloneNode(true);
155:                        clonedOption.setValue(currentDisc.getHandle());
156:                        Node optionTextNode = clonedOption.getOwnerDocument()
157:                                .createTextNode(
158:                                        currentDisc.getArtist() + ": "
159:                                                + currentDisc.getTitle());
160:                        clonedOption.appendChild(optionTextNode);
161:                        // Do only a shallow copy of the option as we don't want the text child
162:                        // of the node option
163:                        discSelect.appendChild(clonedOption);
164:                        // Alternative way to insert nodes below
165:                        // insertBefore(newNode, oldNode);
166:                        // discSelect.insertBefore(clonedOption, templateOption);
167:                    }
168:
169:                    // Finally remove the template row and template select option 
170:                    //  from the page
171:                    templateRow.getParentNode().removeChild(templateRow);
172:                    templateOption.getParentNode().removeChild(templateOption);
173:
174:                } catch (NullPointerException ex) {
175:                    page.setTextErrorText("This is a default HTML page");
176:                } catch (Exception ex) {
177:                    this .writeDebugMsg("Error populating disc catalog: " + ex);
178:                    throw new DiscRackPresentationException(
179:                            "Error getting discs for user: ", ex);
180:                }
181:
182:                // write out HTML
183:                return page;
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.