Source Code Cross Referenced for DiscCatalog.java in  » J2EE » Enhydra-Demos » transactionsDiscRack » 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 » transactionsDiscRack.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:47:00 sinisa Exp $
022:         */
023:
024:        package transactionsDiscRack.presentation.discMgmt;
025:
026:        import transactionsDiscRack.spec.*;
027:        import transactionsDiscRack.presentation.BasePO;
028:        import transactionsDiscRack.presentation.TransactionsDiscRackPresentationException;
029:
030:        import com.lutris.appserver.server.httpPresentation.*;
031:
032:        import org.enhydra.xml.dom.DOMOps;
033:        import org.enhydra.xml.xmlc.*;
034:        import org.w3c.dom.*;
035:        import org.w3c.dom.html.*;
036:
037:        /**
038:         * This class populates discs and display on the page.
039:         * 
040:         */
041:        public class DiscCatalog extends BasePO {
042:
043:            /**
044:             * Superclass method override
045:             */
046:            public boolean loggedInUserRequired() {
047:                return true;
048:            }
049:
050:            /**
051:             * Default event. Just show the page.
052:             * 
053:             * @return html document
054:             * @exception HttpPresentationException
055:             */
056:            public XMLObject handleDefault()
057:                    throws TransactionsDiscRackPresentationException {
058:                // Swap in our real run-time JavaScript to repalce the storyboard
059:                // JavaScript
060:
061:                DiscCatalogHTML page = (DiscCatalogHTML) myComms.xmlcFactory
062:                        .create(DiscCatalogHTML.class);
063:
064:                HTMLScriptElement script = ((DiscCatalogScriptHTML) myComms.xmlcFactory
065:                        .create(DiscCatalogScriptHTML.class))
066:                        .getElementRealScript();
067:                DOMOps.replaceNode(script, page.getElementDummyScript());
068:
069:                /*
070:                 * Catch Null pointer exception ( we canot make a instances of classes
071:                 * from business layer when we run transactionsdiscRack_pres ) We need
072:                 * to allow transactionsdiscRack_pres to be functional , response will
073:                 * be default HTML page
074:                 */
075:
076:                try {
077:
078:                    Disc[] discList = ((DiscGenerator) DiscGeneratorFactory
079:                            .getDiscGenerator("transactionsDiscRack.business.disc.DiscGeneratorImpl"))
080:                            .findDiscsForPerson(this .getUserHandle(),
081:                                    transaction);
082:
083:                    try {
084:                        page.setTextOwner(this .getSessionData()
085:                                .getUserFirstName()
086:                                + " "
087:                                + this .getSessionData().getUserLastName()
088:                                + "'s Discs");
089:                    } catch (Exception ex) {
090:                        writeDebugMsg("Error getting user info: " + ex);
091:                    }
092:
093:                    String errorMsg = this .getSessionData()
094:                            .getAndClearUserMessage();
095:                    if (null == errorMsg) {
096:                        page.getElementErrorText().getParentNode().removeChild(
097:                                page.getElementErrorText());
098:                    } else {
099:                        page.setTextErrorText(errorMsg);
100:                    }
101:
102:                    // Generate the person's Disc list and create the HTML template
103:                    // references
104:                    HTMLTableRowElement templateRow = page
105:                            .getElementTemplateRow();
106:                    HTMLOptionElement templateOption = page
107:                            .getElementTemplateOption();
108:                    Node discTable = templateRow.getParentNode();
109:                    Node discSelect = templateOption.getParentNode();
110:
111:                    // Remove ids to prevent duplicates
112:                    templateRow.removeAttribute("id");
113:                    templateOption.removeAttribute("id");
114:
115:                    // Remove id attributes from the cells in the template row
116:                    HTMLElement artistCellTemplate = page.getElementArtist();
117:                    HTMLElement titleCellTemplate = page.getElementTitle();
118:                    HTMLElement genreCellTemplate = page.getElementGenre();
119:                    HTMLElement likeThisDisc = page.getElementLikeThisDisc();
120:
121:                    artistCellTemplate.removeAttribute("id");
122:                    titleCellTemplate.removeAttribute("id");
123:                    genreCellTemplate.removeAttribute("id");
124:                    likeThisDisc.removeAttribute("id");
125:
126:                    // Remove the dummy storyboard text from the prototype HTML
127:                    templateOption.removeChild(templateOption.getFirstChild());
128:
129:                    // Get collection of Discs and loop through collection
130:                    // to add each disc as a row in the table.
131:                    for (int numDiscs = 0; numDiscs < discList.length; numDiscs++) {
132:                        Disc currentDisc = discList[numDiscs];
133:                        // set text of new cells to values from string array
134:                        page.setTextArtist(currentDisc.getArtist());
135:                        page.setTextTitle(currentDisc.getTitle());
136:                        page.setTextGenre(currentDisc.getGenre());
137:
138:                        if (currentDisc.isLiked()) {
139:                            page.setTextLikeThisDisc("Yes");
140:                        } else {
141:                            page.setTextLikeThisDisc("Not");
142:                        }
143:
144:                        // Add a deep clone of the row to the DOM
145:                        Node clonedNode = templateRow.cloneNode(true);
146:                        discTable.appendChild(clonedNode);
147:                        // Alternative way to insert nodes below
148:                        // insertBefore(newNode, oldNode);
149:                        // discTable.insertBefore(clonedNode, templateRow);
150:
151:                        // Now populate the select list
152:                        // This algorithm is obscure because options are not normal
153:                        // HTML elements
154:                        // First populate the option value (the disc database ID).
155:                        // Then append a text child as the option
156:                        // text, which is what is displayed as the text
157:                        // in each row of the select box
158:                        HTMLOptionElement clonedOption = (HTMLOptionElement) templateOption
159:                                .cloneNode(true);
160:                        clonedOption.setValue(currentDisc.getHandle());
161:                        Node optionTextNode = clonedOption.getOwnerDocument()
162:                                .createTextNode(
163:                                        currentDisc.getArtist() + ": "
164:                                                + currentDisc.getTitle());
165:                        clonedOption.appendChild(optionTextNode);
166:                        // Do only a shallow copy of the option as we don't want the
167:                        // text child
168:                        // of the node option
169:                        discSelect.appendChild(clonedOption);
170:                        // Alternative way to insert nodes below
171:                        // insertBefore(newNode, oldNode);
172:                        // discSelect.insertBefore(clonedOption, templateOption);
173:                    }
174:
175:                    // Finally remove the template row and template select option
176:                    // from the page
177:                    templateRow.getParentNode().removeChild(templateRow);
178:                    templateOption.getParentNode().removeChild(templateOption);
179:
180:                } catch (NullPointerException ex) {
181:                    page.setTextErrorText("This is a default HTML page");
182:                } catch (Exception ex) {
183:                    writeDebugMsg("Error populating disc catalog: " + ex);
184:                    throw new TransactionsDiscRackPresentationException(
185:                            "Error getting discs for user: ", ex);
186:                }
187:
188:                // write out HTML
189:                return page;
190:            }
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.