Source Code Cross Referenced for AbstractAjaxBehavior.java in  » J2EE » wicket » org » apache » wicket » behavior » 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 » wicket » org.apache.wicket.behavior 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.wicket.behavior;
018:
019:        import org.apache.wicket.Component;
020:        import org.apache.wicket.RequestListenerInterface;
021:        import org.apache.wicket.Response;
022:        import org.apache.wicket.markup.ComponentTag;
023:        import org.apache.wicket.markup.html.IHeaderContributor;
024:        import org.apache.wicket.markup.html.IHeaderResponse;
025:        import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
026:        import org.apache.wicket.util.string.AppendingStringBuffer;
027:
028:        /**
029:         * Abstract class for handling Ajax roundtrips. This class serves as a base for
030:         * javascript specific implementations, like ones based on Dojo or
031:         * Scriptaculous, or Wicket's default.
032:         * 
033:         * @author Eelco Hillenius
034:         * @author Ralf Ebert
035:         * @author Igor Vaynberg
036:         */
037:        public abstract class AbstractAjaxBehavior extends AbstractBehavior
038:                implements  IBehaviorListener, IHeaderContributor {
039:            /** the component that this handler is bound to. */
040:            private Component component;
041:
042:            /**
043:             * Construct.
044:             */
045:            public AbstractAjaxBehavior() {
046:            }
047:
048:            /**
049:             * Bind this handler to the given component.
050:             * 
051:             * @param hostComponent
052:             *            the component to bind to
053:             */
054:            public final void bind(final Component hostComponent) {
055:                if (hostComponent == null) {
056:                    throw new IllegalArgumentException(
057:                            "Argument hostComponent must be not null");
058:                }
059:
060:                if (this .component != null) {
061:                    throw new IllegalStateException(
062:                            "this kind of handler cannot be attached to "
063:                                    + "multiple components; it is already attached to component "
064:                                    + this .component + ", but component "
065:                                    + hostComponent
066:                                    + " wants to be attached too");
067:
068:                }
069:
070:                this .component = hostComponent;
071:
072:                // call the calback
073:                onBind();
074:            }
075:
076:            /**
077:             * Gets the url that references this handler.
078:             * 
079:             * @return the url that references this handler
080:             */
081:            public CharSequence getCallbackUrl() {
082:                return getCallbackUrl(true);
083:            }
084:
085:            /**
086:             * Gets the url that references this handler.
087:             * 
088:             * @param onlyTargetActivePage
089:             *            if true the callback to this behavior will be ignore if the
090:             *            page is not the last one the user accessed
091:             * 
092:             * @return the url that references this handler
093:             */
094:            public final CharSequence getCallbackUrl(
095:                    final boolean onlyTargetActivePage) {
096:                if (getComponent() == null) {
097:                    throw new IllegalArgumentException(
098:                            "Behavior must be bound to a component to create the URL");
099:                }
100:
101:                final RequestListenerInterface rli;
102:
103:                rli = IBehaviorListener.INTERFACE;
104:
105:                AppendingStringBuffer url = new AppendingStringBuffer(
106:                        getComponent().urlFor(this , rli));
107:
108:                if (onlyTargetActivePage) {
109:                    url
110:                            .append("&")
111:                            .append(
112:                                    WebRequestCodingStrategy.IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME)
113:                            .append("=true");
114:                }
115:
116:                return url;
117:            }
118:
119:            /**
120:             * @see org.apache.wicket.behavior.IBehavior#onComponentTag(org.apache.wicket.Component,
121:             *      org.apache.wicket.markup.ComponentTag)
122:             */
123:            public final void onComponentTag(final Component component,
124:                    final ComponentTag tag) {
125:                onComponentTag(tag);
126:            }
127:
128:            /**
129:             * @see org.apache.wicket.behavior.AbstractBehavior#onRendered(org.apache.wicket.Component)
130:             */
131:            public final void onRendered(final Component hostComponent) {
132:                onComponentRendered();
133:            }
134:
135:            /**
136:             * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(IHeaderResponse)
137:             */
138:            public void renderHead(final IHeaderResponse response) {
139:            }
140:
141:            /**
142:             * Gets the component that this handler is bound to.
143:             * 
144:             * @return the component that this handler is bound to
145:             */
146:            protected final Component getComponent() {
147:                return component;
148:            }
149:
150:            /**
151:             * Called any time a component that has this handler registered is rendering
152:             * the component tag. Use this method e.g. to bind to javascript event
153:             * handlers of the tag
154:             * 
155:             * @param tag
156:             *            the tag that is rendered
157:             */
158:            protected void onComponentTag(final ComponentTag tag) {
159:            }
160:
161:            /**
162:             * Called when the component was bound to it's host component. You can get
163:             * the bound host component by calling getComponent.
164:             */
165:            protected void onBind() {
166:            }
167:
168:            /**
169:             * Called to indicate that the component that has this handler registered
170:             * has been rendered. Use this method to do any cleaning up of temporary
171:             * state
172:             */
173:            protected void onComponentRendered() {
174:            }
175:
176:            /**
177:             * @see org.apache.wicket.behavior.AbstractBehavior#getStatelessHint(Component)
178:             */
179:            public boolean getStatelessHint(Component component) {
180:                return false;
181:            }
182:
183:            // TODO the next three methods will be removed with next commit. Here as
184:            // final to help with refactoring
185:
186:            protected final String getImplementationId() {
187:                return "foo";
188:            }
189:
190:            protected final void onRenderHeadContribution(
191:                    final Response response) {
192:            }
193:
194:            protected final void onRenderHeadInitContribution(
195:                    final Response response) {
196:            }
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.