Source Code Cross Referenced for ShowWindowEventListener.java in  » Ajax » zk » org » zkoss » zkplus » acegi » 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 » Ajax » zk » org.zkoss.zkplus.acegi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* AcegiAuthenticationEntryPoint.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Thu Dec 27 11:32:06     2006, Created by Henri
010:        }}IS_NOTE
011:
012:        Copyright (C) 2006 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        }}IS_RIGHT
016:         */
017:        package org.zkoss.zkplus.acegi;
018:
019:        import org.zkoss.zk.ui.Page;
020:        import org.zkoss.zk.ui.Component;
021:        import org.zkoss.zk.ui.UiException;
022:        import org.zkoss.zk.ui.event.Event;
023:        import org.zkoss.zk.ui.event.Events;
024:        import org.zkoss.zk.ui.event.EventListener;
025:        import org.zkoss.zk.ui.Execution;
026:        import org.zkoss.zk.ui.Executions;
027:        import org.zkoss.zk.ui.UiException;
028:
029:        import org.zkoss.zk.ui.Page;
030:        import org.zkoss.zk.ui.Component;
031:        import org.zkoss.zk.ui.UiException;
032:        import org.zkoss.zk.ui.event.Event;
033:        import org.zkoss.zk.ui.event.Events;
034:        import org.zkoss.zk.ui.event.EventListener;
035:        import org.zkoss.zk.ui.Execution;
036:        import org.zkoss.zk.ui.Executions;
037:        import org.zkoss.zk.ui.UiException;
038:
039:        import org.zkoss.zul.Textbox;
040:        import org.zkoss.zul.Window;
041:
042:        import org.zkoss.util.CollectionsX;
043:
044:        import java.util.Map;
045:        import java.util.HashMap;
046:        import java.util.List;
047:        import java.util.ArrayList;
048:        import java.util.Iterator;
049:
050:        /**
051:         * <p>The default listener to show a modal window for login and other things.</p>
052:         * <p>The event data is the url page and it expects:</p>
053:         * <ul>
054:         * <li>The url page must be a zul defined page (*.zul).</li>
055:         * <li>The url page must enclosed with a window component so it can be doModal().</li>
056:         * </ul>
057:         * <p>This implementation would automatically remove the added eventlistener from the target component.</p>
058:         *
059:         * @author Henri
060:         */
061:        public class ShowWindowEventListener implements  EventListener {
062:            public void onEvent(Event event) {
063:                //fetch old Event stored in Session and post again
064:                final Component comp = event.getTarget();
065:
066:                final Page page = comp.getPage();
067:                final String url = (String) event.getData();
068:                final Execution exec = Executions.getCurrent();
069:                try {
070:                    doModal(page, url);
071:                } finally {
072:                    if (comp.isListenerAvailable(event.getName(), true)) {
073:                        EventListener listener = (EventListener) comp
074:                                .getAttribute(event.getName());
075:                        if (listener != null) {
076:                            comp.removeEventListener(event.getName(), listener);
077:                            comp.removeAttribute(event.getName());
078:                        }
079:                    }
080:                }
081:            }
082:
083:            private void doModal(Page page, String url) {
084:                final Execution exec = Executions.getCurrent();
085:                final Object[] urls = parseUrl(url);
086:                final Component modalwin = exec.createComponents(
087:                        (String) urls[0], null, (Map) urls[1]);
088:                if (!(modalwin instanceof  Window)) {
089:                    throw new UiException(
090:                            "The page must enclosed with a Window component. Check url definition: "
091:                                    + url);
092:                }
093:                modalwin.setPage(page);
094:                try {
095:                    ((Window) modalwin).doModal();
096:                } catch (java.lang.InterruptedException ex) {
097:                    //ignore
098:                }
099:            }
100:
101:            //Object[0]: url, Object[1]: Map
102:            private Object[] parseUrl(String url) {
103:                Object[] result = new Object[2];
104:                int j = url.indexOf("?");
105:                if (j < 0) {
106:                    result[0] = url;
107:                    return result;
108:                }
109:                result[0] = url.substring(0, j);
110:
111:                if ((j + 1) >= url.length()) {
112:                    return result;
113:                }
114:
115:                url = url.substring(j + 1);
116:                List list = (List) CollectionsX
117:                        .parse(new ArrayList(), url, '&');
118:                Map args = new HashMap();
119:                for (final Iterator it = list.iterator(); it.hasNext();) {
120:                    List pair = (List) CollectionsX.parse(new ArrayList(2),
121:                            (String) it.next(), '=');
122:                    args.put(pair.get(0), pair.get(1));
123:                }
124:
125:                result[1] = args;
126:                return result;
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.