Source Code Cross Referenced for CalculatorLookupController.java in  » J2EE » Sofia » com » salmonllc » examples » example19 » 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 » Sofia » com.salmonllc.examples.example19 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //package statement
002:        package com.salmonllc.examples.example19;
003:
004:        //Salmon import statements
005:        import java.text.DecimalFormat;
006:        import java.util.Enumeration;
007:
008:        import com.salmonllc.html.HtmlButton;
009:        import com.salmonllc.html.HtmlComponent;
010:        import com.salmonllc.html.HtmlLookUpComponent;
011:        import com.salmonllc.html.HtmlScriptGenerator;
012:        import com.salmonllc.html.events.PageEvent;
013:        import com.salmonllc.html.events.PageListener;
014:        import com.salmonllc.jsp.JspController;
015:        import com.salmonllc.properties.Props;
016:
017:        //The Salmon Open Framework for Internet Applications (SOFIA)
018:        //Copyright (C) 1999 - 2002, Salmon LLC
019:        //
020:        //This program is free software; you can redistribute it and/or
021:        //modify it under the terms of the GNU General Public License version 2
022:        //as published by the Free Software Foundation; 
023:        //
024:        //This program is distributed in the hope that it will be useful,
025:        //but WITHOUT ANY WARRANTY; without even the implied warranty of
026:        //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
027:        //GNU General Public License for more details.
028:        //
029:        //You should have received a copy of the GNU General Public License
030:        //along with this program; if not, write to the Free Software
031:        //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
032:        //
033:        //For more information please visit http://www.salmonllc.com
034:
035:        /**
036:         * CalculatorController: The controller for the  Drop Down Calculator
037:         * This demonstrates how you can create your own type of popup using SOFIA component
038:         * The calculator isn't a SOFIA component itself, but is constructed out of SOFIA components and javascript
039:         */
040:        public class CalculatorLookupController extends JspController implements 
041:                PageListener {
042:            public com.salmonllc.html.HtmlButton _buttonCancel;
043:            public com.salmonllc.html.HtmlButton _buttonEnter;
044:            public com.salmonllc.html.HtmlTextEdit _text1;
045:
046:            /**
047:             * Initialize the page. Set up listeners and perform other initialization activities.
048:             */
049:            public void initialize() {
050:                addPageListener(this );
051:
052:                //For IE, mousedown and double click is more responsive then onclick so copy all the javascript from one to the other
053:                if (getBrowserType() == BROWSER_MICROSOFT) {
054:                    Enumeration en = getComponents();
055:                    while (en.hasMoreElements()) {
056:                        HtmlComponent comp = (HtmlComponent) en.nextElement();
057:                        if (comp instanceof  HtmlButton) {
058:                            HtmlButton b = (HtmlButton) comp;
059:                            b.setOnMouseDown(b.getOnClick());
060:                            b.setOnDoubleClick(b.getOnClick());
061:                            b.setOnClick(null);
062:                        }
063:                    }
064:                }
065:
066:            }
067:
068:            /**
069:             * Process the page requested event
070:             * @param event the page event to be processed
071:             */
072:            public void pageRequested(PageEvent event) {
073:                if (!isReferredByCurrentPage()) {
074:                    //set the appropriate script for the cancel button
075:                    HtmlScriptGenerator gen = new HtmlScriptGenerator(this );
076:                    _buttonCancel.setOnClick(gen.generateCancelLookupScript());
077:
078:                    //set value and the max length in the text box in the calculator
079:                    _text1.setMaxLength(HtmlLookUpComponent
080:                            .getParentLookupMaxLength(this ));
081:                    _text1.setValue(HtmlLookUpComponent
082:                            .getParentLookupValue(this ));
083:
084:                    //set focus to the window
085:                    writeScript("document.forms[0]."
086:                            + _buttonEnter.getFullName() + ".focus();");
087:
088:                    //set the background color so this matchs the calendar lookup
089:                    Props p = getPageProperties();
090:                    setBackgroundColor(p
091:                            .getProperty(Props.CAL_WEEK_BACKGROUND_COLOR));
092:
093:                }
094:            }
095:
096:            public void pageRequestEnd(PageEvent event) {
097:            }
098:
099:            /**
100:             * Fired when the user hits the Enter button 
101:             */
102:            public void pageSubmitEnd(PageEvent event) {
103:                //Take the value from the calculator, format it and copy the value back to the field
104:                HtmlLookUpComponent comp = getPopupLookupComponent();
105:                String lookupFormat = comp.getEditField().getDisplayFormat();
106:                HtmlScriptGenerator gen = new HtmlScriptGenerator(this );
107:                String numVal = _text1.getValue();
108:                if (numVal == null)
109:                    numVal = "";
110:                if (lookupFormat != null) {
111:                    try {
112:                        double dv = Double.parseDouble(numVal);
113:                        DecimalFormat df = new DecimalFormat(lookupFormat);
114:                        numVal = df.format(dv);
115:                    } catch (Exception ex) {
116:                    }
117:                }
118:                writeScript(gen.generateReturnValueToLookupScript(numVal, ""));
119:            }
120:
121:            /**
122:             * Process the page submit event
123:             * @param event the page event to be processed
124:             */
125:            public void pageSubmitted(PageEvent event) {
126:            }
127:
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.