Source Code Cross Referenced for BodyContainer.java in  » J2EE » wicket » wicket » markup » html » 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 » wicket.markup.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: BodyContainer.java 460546 2006-05-06 09:09:53Z jcompagner $ $Revision:
003:         * 5436 $ $Date: 2006-05-06 11:09:53 +0200 (Sat, 06 May 2006) $
004:         * 
005:         * ==============================================================================
006:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
007:         * use this file except in compliance with the License. You may obtain a copy of
008:         * the License at
009:         * 
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015:         * License for the specific language governing permissions and limitations under
016:         * the License.
017:         */
018:        package wicket.markup.html;
019:
020:        import java.io.Serializable;
021:
022:        import wicket.AttributeModifier;
023:        import wicket.Component;
024:        import wicket.markup.html.body.BodyTagAttributeModifier;
025:        import wicket.model.IModel;
026:        import wicket.model.Model;
027:
028:        /**
029:         * This is not realy a Container component in the standard Wicket sense. It
030:         * rather is a facade which allows to easily add attribute modifier to the
031:         * MarkupContainer associated with <body>. That container might be a
032:         * Wicket generated one (automatically) or one manually added by a user the
033:         * standard Wicket way.
034:         * <p>
035:         * Container for the page body. This is mostly an internal class that is used
036:         * for contributions to the body tag's onload event handler.
037:         * 
038:         * @author jcompagner
039:         * 
040:         * TODO Post 1.2: Change the name. It is not derived from MarkupContainer
041:         */
042:        public final class BodyContainer implements  Serializable {
043:            private static final long serialVersionUID = 1L;
044:
045:            /** The webpage where the body container is in */
046:            private final WebPage page;
047:
048:            /** The container id */
049:            private final String id;
050:
051:            /**
052:             * Construct.
053:             * 
054:             * @param page
055:             *            The webpage where the body container is in
056:             * @param id
057:             *            The container id
058:             */
059:            public BodyContainer(final WebPage page, final String id) {
060:                this .page = page;
061:                this .id = id;
062:            }
063:
064:            /**
065:             * Add a new AttributeModifier to the body container which appends the
066:             * 'value' to the onLoad attribute of the body tag.
067:             * <p>
068:             * Note: This method is not suitable for
069:             * 
070:             * @param value
071:             *            The value to append to 'onLoad'
072:             * @return this
073:             * @deprecated use {@link #addOnLoadModifier(String, Component)} instead
074:             */
075:            public final BodyContainer addOnLoadModifier(final String value) {
076:                final Model model = new Model(value);
077:                final Component bodyContainer = page.get(id);
078:
079:                // TODO Post 1.2: Move all attribute modifier into a separate package
080:                // and add an AppendingAttributeModifier to that package
081:                bodyContainer.add(new AppendingAttributeModifier("onload",
082:                        model));
083:                return this ;
084:            }
085:
086:            /**
087:             * Add a new AttributeModifier to the body container which appends the
088:             * 'value' to the onLoad attribute of the body tag.
089:             * 
090:             * @param model
091:             *            The model that holds the value that must be appended to
092:             *            'onLoad'
093:             * @return this
094:             * @deprecated use {@link #addOnLoadModifier(IModel, Component)} instead
095:             */
096:            public final BodyContainer addOnLoadModifier(final IModel model) {
097:                final Component bodyContainer = page.get(id);
098:                bodyContainer.add(new AppendingAttributeModifier("onload",
099:                        model));
100:                return this ;
101:            }
102:
103:            /**
104:             * Add a new AttributeModifier to the body container which appends the
105:             * 'value' to the onUnLoad attribute of the body tag.
106:             * 
107:             * @param value
108:             *            The value to append to 'onUnLoad'
109:             * @return this
110:             * @deprecated use {@link #addOnUnLoadModifier(String, Component)} instead
111:             */
112:            public final BodyContainer addOnUnLoadModifier(final String value) {
113:                final IModel model = new Model(value);
114:                final Component bodyContainer = page.get(id);
115:                bodyContainer.add(new AppendingAttributeModifier("onunload",
116:                        model));
117:                return this ;
118:            }
119:
120:            /**
121:             * Add a new AttributeModifier to the body container which appends the value
122:             * of the model to the onUnLoad attribute of the body tag.
123:             * 
124:             * @param model
125:             *            The model which holds the value to be appended to 'onUnLoad'
126:             * @return this
127:             * @deprecated use {@link #addOnUnLoadModifier(IModel, Component)} instead
128:             */
129:            public final BodyContainer addOnUnLoadModifier(final IModel model) {
130:                final Component bodyContainer = page.get(id);
131:                bodyContainer.add(new AppendingAttributeModifier("onunload",
132:                        model));
133:                return this ;
134:            }
135:
136:            /**
137:             * Little helper
138:             */
139:            public static class AppendingAttributeModifier extends
140:                    AttributeModifier {
141:                private static final long serialVersionUID = 1L;
142:
143:                /**
144:                 * Construct.
145:                 * 
146:                 * @param attribute
147:                 * @param replaceModel
148:                 */
149:                public AppendingAttributeModifier(final String attribute,
150:                        IModel replaceModel) {
151:                    super (attribute, true, replaceModel);
152:                }
153:
154:                protected String newValue(final String currentValue,
155:                        final String replacementValue) {
156:                    if (currentValue != null
157:                            && !currentValue.trim().endsWith(";")) {
158:                        return currentValue + ";" + replacementValue;
159:                    }
160:                    return (currentValue == null ? replacementValue
161:                            : currentValue + replacementValue);
162:                }
163:            }
164:
165:            /**
166:             * Get the real body container (WebMarkupContainer)
167:             * 
168:             * @return WebMarkupContainer associated with the &lt;body&gt; tag
169:             */
170:            public WebMarkupContainer getBodyContainer() {
171:                return (WebMarkupContainer) this .page.get(this .id);
172:            }
173:
174:            /**
175:             * Add a new AttributeModifier to the body container which appends the
176:             * 'value' to the onLoad attribute of the body tag. Remember the component
177:             * which requested to add the modified to the body container. This for
178:             * example is required in cases where on a dynamic page the Component (e.g.
179:             * a Panel) gets removed and/or replaced and the body attribute modifier
180:             * must be removed/replaced as well.
181:             * 
182:             * @param value
183:             *            The value to append to 'onLoad'
184:             * @param behaviorOwner
185:             *            The component which 'owns' the attribute modifier. Null is a allowed value.
186:             * @return this
187:             * 
188:             * @TODO Post 1.2: A listener hook on IBheavior which gets called on removal
189:             *       of the component would be the better solution
190:             */
191:            public final BodyContainer addOnLoadModifier(final String value,
192:                    final Component behaviorOwner) {
193:                final IModel model = new Model(value);
194:                return addOnLoadModifier(model, behaviorOwner);
195:            }
196:
197:            /**
198:             * Add a new AttributeModifier to the body container which appends the
199:             * 'value' to the onLoad attribute of the body tag. Remember the component
200:             * which requested to add the modified to the body container. This for
201:             * example is required in cases where on a dynamic page the Component (e.g.
202:             * a Panel) gets removed and/or replaced and the body attribute modifier
203:             * must be removed/replaced as well.
204:             * 
205:             * @param model
206:             *            The model which holds the value to be appended to 'onLoad'
207:             * @param behaviorOwner
208:             *            The component which 'owns' the attribute modifier. Null is a allowed value.
209:             * @return this
210:             * 
211:             * @TODO Post 1.2: A listener hook on IBheavior which gets called on removal
212:             *       of the component would be the better solution
213:             */
214:            public final BodyContainer addOnLoadModifier(final IModel model,
215:                    final Component behaviorOwner) {
216:                if (behaviorOwner == null) {
217:                    return addOnLoadModifier(model);
218:                }
219:
220:                final Component bodyContainer = page.get(id);
221:                bodyContainer.add(new BodyTagAttributeModifier("onload", true,
222:                        model, behaviorOwner));
223:                return this ;
224:            }
225:
226:            /**
227:             * Add a new AttributeModifier to the body container which appends the
228:             * 'value' to the onUnLoad attribute of the body tag. Remember the component
229:             * which requested to add the modified to the body container. This for
230:             * example is required in cases where on a dynamic page the Component (e.g.
231:             * a Panel) gets removed and/or replaced and the body attribute modifier
232:             * must be removed/replaced as well.
233:             * 
234:             * @param value
235:             *            The value to append to 'onUnLoad'
236:             * @param behaviorOwner
237:             *            The component which 'owns' the attribute modifier. Null is a allowed value.
238:             * @return this
239:             * 
240:             * @TODO Post 1.2: A listener hook on IBehavior which gets called on removal
241:             *       of the component would be the better solution
242:             */
243:            public final BodyContainer addOnUnLoadModifier(final String value,
244:                    final Component behaviorOwner) {
245:                final IModel model = new Model(value);
246:                return addOnUnLoadModifier(model, behaviorOwner);
247:            }
248:
249:            /**
250:             * Add a new AttributeModifier to the body container which appends the
251:             * 'value' to the onUnLoad attribute of the body tag. Remember the component
252:             * which requested to add the modified to the body container. This for
253:             * example is required in cases where on a dynamic page the Component (e.g.
254:             * a Panel) gets removed and/or replaced and the body attribute modifier
255:             * must be removed/replaced as well.
256:             * 
257:             * @param model
258:             *            The model which holds the value to be appended to 'onUnLoad'
259:             * @param behaviorOwner
260:             *            The component which 'owns' the attribute modifier. Null is a allowed value.
261:             * @return this
262:             * 
263:             * @TODO Post 1.2: A listener hook on IBheavior which gets called on removal
264:             *       of the component would be the better solution
265:             */
266:            public final BodyContainer addOnUnLoadModifier(final IModel model,
267:                    final Component behaviorOwner) {
268:                if (behaviorOwner == null) {
269:                    return addOnUnLoadModifier(model);
270:                }
271:
272:                final Component bodyContainer = page.get(id);
273:                bodyContainer.add(new BodyTagAttributeModifier("onunload",
274:                        true, model, behaviorOwner));
275:                return this;
276:            }
277:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.