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


001:        //The Salmon Open Framework for Internet Applications (SOFIA)
002:        //Copyright (C) 1999 - 2002, Salmon LLC
003:        //
004:        //This program is free software; you can redistribute it and/or
005:        //modify it under the terms of the GNU General Public License version 2
006:        //as published by the Free Software Foundation;
007:        //
008:        //This program is distributed in the hope that it will be useful,
009:        //but WITHOUT ANY WARRANTY; without even the implied warranty of
010:        //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011:        //GNU General Public License for more details.
012:        //
013:        //You should have received a copy of the GNU General Public License
014:        //along with this program; if not, write to the Free Software
015:        //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
016:        //
017:        //For more information please visit http://www.salmonllc.com
018:
019:        package com.salmonllc.examples.example16;
020:
021:        import com.salmonllc.jsp.*;
022:        import com.salmonllc.examples.SiteMapConstants;
023:        import com.salmonllc.html.events.*;
024:        import com.salmonllc.personalization.SkinManager;
025:        import com.salmonllc.personalization.Skin;
026:
027:        /**
028:         * An example of how to use the SOFIA personalization package to change the look and feel of your application
029:         */
030:        public class PersonalizationController extends JspController implements 
031:                SubmitListener, PageListener {
032:
033:            //Visual Components
034:            public com.salmonllc.html.HtmlDropDownList _swingSkin;
035:            public com.salmonllc.html.HtmlDropDownList _webSkin;
036:            public com.salmonllc.html.HtmlSubmitButton _apply;
037:            public com.salmonllc.html.HtmlSubmitButton _customizeSwing;
038:            public com.salmonllc.html.HtmlSubmitButton _customizeWeb;
039:            public com.salmonllc.jsp.JspForm _pageForm;
040:
041:            public com.salmonllc.html.HtmlText _capSwingSkin;
042:            public com.salmonllc.html.HtmlText _capWebSkin;
043:
044:            public void initialize() {
045:                loadDropDowns();
046:
047:                _pageForm.addSubmitListener(this );
048:                _apply.addSubmitListener(this );
049:                _customizeWeb.addSubmitListener(this );
050:                _customizeSwing.addSubmitListener(this );
051:                addPageListener(this );
052:            }
053:
054:            public boolean submitPerformed(SubmitEvent e) throws Exception {
055:                if (e.getSource() == _apply)
056:                    apply();
057:                else if (e.getSource() == _pageForm) {
058:                    _customizeWeb.setEnabled(!_webSkin.getValue()
059:                            .equals("none"));
060:                    _customizeSwing.setEnabled(_swingSkin.getValue().indexOf(
061:                            "Metal-") > -1
062:                            || _swingSkin.getValue().indexOf("User") > -1);
063:                    _apply.setEnabled(true);
064:                } else if (e.getSource() == _customizeWeb)
065:                    gotoSiteMapPage(SiteMapConstants.PERSONALIZATION_WEB,
066:                            "?skin=browser" + _webSkin.getValue());
067:                else if (e.getSource() == _customizeSwing)
068:                    gotoSiteMapPage(SiteMapConstants.PERSONALIZATION_SWING,
069:                            "?skin=swing" + _swingSkin.getValue());
070:
071:                return true;
072:            }
073:
074:            /**
075:             * This event will get fired each time a page is requested by the browser before any HTML is generated.
076:             */
077:            public void pageRequested(PageEvent p) throws Exception {
078:                if (!isReferredByCurrentPage()) {
079:                    String webSkin = getParameter("webSkin");
080:                    String swingSkin = getParameter("swingSkin");
081:                    if (webSkin != null || swingSkin != null) {
082:                        loadDropDowns();
083:                        if (webSkin != null)
084:                            _webSkin.setValue(webSkin.substring(7));
085:                        if (swingSkin != null)
086:                            _swingSkin.setValue(swingSkin.substring(5));
087:                        apply();
088:                    }
089:                }
090:            }
091:
092:            /**
093:             * This event will get fired each time a page is requested by the browser after any HTML is generated.
094:             */
095:            public void pageRequestEnd(PageEvent p) throws Exception {
096:            }
097:
098:            /**
099:             * This method occurs each time a page is submitted before values are copied from the HTML form to the framework component representing input fields.
100:             */
101:            public void pageSubmitEnd(PageEvent p) {
102:            }
103:
104:            /**
105:             * This method occurs each time a page is submitted after all the values submitted from the HTML form are copied to framework components representing them.
106:             */
107:            public void pageSubmitted(PageEvent p) {
108:            }
109:
110:            private void apply() {
111:                String webSkin = _webSkin.getValue();
112:                String swingSkin = _swingSkin.getValue();
113:                SkinManager man = SkinManager
114:                        .getSkinManager(getApplicationName());
115:                Skin skin = new Skin();
116:                if (webSkin != null)
117:                    man.load("browser" + webSkin, skin);
118:                if (swingSkin != null)
119:                    man.load("swing" + swingSkin, skin);
120:                clearAllPagesFromSessionButCurrent();
121:                setDefaultSkin(skin, true);
122:            }
123:
124:            private void loadDropDowns() {
125:                //get the default skin manager to populat the drop down lists
126:                SkinManager man = SkinManager
127:                        .getSkinManager(getApplicationName());
128:                String skin[] = man.getSkinNames();
129:                //we use a naming convention to seperate the swing skins from the web ones. Swing ones start with swing.
130:                _webSkin.resetOptions();
131:                _swingSkin.resetOptions();
132:                _webSkin.addOption("none", "Default");
133:                _swingSkin.addOption("none", "Default");
134:                for (int i = 0; i < skin.length; i++) {
135:                    if (skin[i].startsWith("swing")) {
136:                        String val = skin[i].substring(5);
137:                        _swingSkin.addOption(val, val);
138:                    } else if (skin[i].startsWith("browser")) {
139:                        String val = skin[i].substring(7);
140:                        _webSkin.addOption(val, val);
141:                    }
142:                }
143:            }
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.