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