View File | Revision Log | Show Annotations | Download File | View Changeset
/hippo/experimental/hippo-jcr-console/trunk/jcr-repo-console/WICKET-3927_2.patch
Revision: 29590
Committed: Mon Aug 15 21:57:18 2011 UTC (11 years, 1 month ago) by wko
File size: 14720 byte(s)
Log Message:
JCR-25: cloning all Hippo Console modules as sibling JCR Console modules

File Contents

# Content
1 Index: src/main/java/org/apache/wicket/markup/html/internal/HeaderResponse.java
2 ===================================================================
3 --- src/main/java/org/apache/wicket/markup/html/internal/HeaderResponse.java (revision 1030625)
4 +++ src/main/java/org/apache/wicket/markup/html/internal/HeaderResponse.java (revision )
5 @@ -77,6 +77,21 @@
6 }
7
8 /**
9 + * @see org.apache.wicket.markup.html.IHeaderResponse#renderCSSReference(org.apache.wicket.ResourceReference, boolean)
10 + */
11 + public void renderCSSReference(ResourceReference reference, boolean cacheBeforeRender) {
12 + if (reference == null)
13 + {
14 + throw new IllegalArgumentException("reference cannot be null");
15 + }
16 + if (!closed)
17 + {
18 + CharSequence url = RequestCycle.get().urlFor(reference);
19 + renderCSSReference(url.toString(), null, cacheBeforeRender);
20 + }
21 + }
22 +
23 + /**
24 * @see org.apache.wicket.markup.html.IHeaderResponse#renderCSSReference(org.apache.wicket.ResourceReference,
25 * java.lang.String)
26 */
27 @@ -94,6 +109,21 @@
28 }
29
30 /**
31 + * @see org.apache.wicket.markup.html.IHeaderResponse#renderCSSReference(org.apache.wicket.ResourceReference, String, boolean)
32 + */
33 + public void renderCSSReference(ResourceReference reference, String media, boolean cacheBeforeRender) {
34 + if (reference == null)
35 + {
36 + throw new IllegalArgumentException("reference cannot be null");
37 + }
38 + if (!closed)
39 + {
40 + CharSequence url = RequestCycle.get().urlFor(reference);
41 + renderCSSReference(url.toString(), media, cacheBeforeRender);
42 + }
43 + }
44 +
45 + /**
46 * @see org.apache.wicket.markup.html.IHeaderResponse#renderCSSReference(java.lang.String)
47 */
48 public void renderCSSReference(String url)
49 @@ -109,11 +139,19 @@
50 }
51
52 /**
53 - * @see org.apache.wicket.markup.html.IHeaderResponse#renderCSSReference(java.lang.String,
54 - * java.lang.String)
55 + * @see org.apache.wicket.markup.html.IHeaderResponse#renderCSSReference(String, String)
56 */
57 public void renderCSSReference(String url, String media)
58 {
59 + renderCSSReference(url, media, false);
60 + }
61 +
62 + /**
63 + * @see org.apache.wicket.markup.html.IHeaderResponse#renderCSSReference(String, String)
64 + * @param cacheBeforeRender
65 + * if true ensures the css is rendered before other references are rendered, otherwise not
66 + */
67 + private void renderCSSReference(String url, String media, boolean cacheBeforeRender) {
68 if (Strings.isEmpty(url))
69 {
70 throw new IllegalArgumentException("url cannot be empty or null");
71 @@ -123,9 +161,12 @@
72 List<Object> token = Arrays.asList(new Object[] { "css", url, media });
73 if (wasRendered(token) == false)
74 {
75 - getResponse().write("<link rel=\"stylesheet\" type=\"text/css\" href=\"");
76 + getResponse().write("<link rel=\"stylesheet\" type=\"text/css\" href=\"");
77 getResponse().write(url);
78 getResponse().write("\"");
79 + if (cacheBeforeRender) {
80 + getResponse().write(" cacheBeforeRender=\"cacheBeforeRender\" ");
81 + }
82 if (media != null)
83 {
84 getResponse().write(" media=\"");
85 @@ -136,8 +177,7 @@
86 markRendered(token);
87 }
88 }
89 - }
90 + }
91 -
92 /**
93 * @see org.apache.wicket.markup.html.IHeaderResponse#renderJavascriptReference(org.apache.wicket.ResourceReference)
94 */
95 Index: src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
96 ===================================================================
97 --- src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java (revision 1049685)
98 +++ src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java (revision )
99 @@ -958,6 +958,15 @@
100 }
101
102 @Override
103 + public void renderCSSReference(final ResourceReference reference, final String media, final boolean cacheBeforeRender)
104 + {
105 + if (checkHeaderRendering())
106 + {
107 + super.renderCSSReference(reference, media, cacheBeforeRender);
108 + }
109 + }
110 +
111 + @Override
112 public void renderCSSReference(String url)
113 {
114 if (checkHeaderRendering())
115 @@ -993,7 +1002,16 @@
116 }
117 }
118
119 - @Override
120 + @Override
121 + public void renderCSSReference(ResourceReference reference, boolean cacheBeforeRender)
122 + {
123 + if (checkHeaderRendering())
124 + {
125 + super.renderCSSReference(reference, cacheBeforeRender);
126 + }
127 + }
128 +
129 + @Override
130 public void renderJavascriptReference(ResourceReference reference)
131 {
132 if (checkHeaderRendering())
133 Index: src/main/java/org/apache/wicket/markup/html/CSSPackageResource.java
134 ===================================================================
135 --- src/main/java/org/apache/wicket/markup/html/CSSPackageResource.java (revision 731096)
136 +++ src/main/java/org/apache/wicket/markup/html/CSSPackageResource.java (revision )
137 @@ -32,7 +32,7 @@
138 */
139 public class CSSPackageResource extends PackageResource
140 {
141 - private static final long serialVersionUID = 1L;;
142 + private static final long serialVersionUID = 1L;
143
144 /**
145 * Returns a new instance of {@link HeaderContributor} with a header contributor that references
146 @@ -48,13 +48,32 @@
147 public static final HeaderContributor getHeaderContribution(final Class<?> scope,
148 final String path)
149 {
150 + return getHeaderContribution(scope, path, false);
151 + }
152 +
153 + /**
154 + * Returns a new instance of {@link HeaderContributor} with a header contributor that references
155 + * a CSS file that lives in a package.
156 + *
157 + * @param scope
158 + * The scope of the package resource (typically the class of the caller, or a class
159 + * that lives in the package where the resource lives).
160 + * @param path
161 + * The path
162 + * @param cacheBeforeRender
163 + * if true, the resource will be pre cached by the browser before it gets rendered (if cache is turned on)
164 + * @return the new header contributor instance
165 + */
166 + public static final HeaderContributor getHeaderContribution(final Class<?> scope,
167 + final String path, final boolean cacheBeforeRender)
168 + {
169 return new HeaderContributor(new IHeaderContributor()
170 {
171 private static final long serialVersionUID = 1L;
172
173 public void renderHead(IHeaderResponse response)
174 {
175 - response.renderCSSReference(new CompressedResourceReference(scope, path));
176 + response.renderCSSReference(new CompressedResourceReference(scope, path), cacheBeforeRender);
177 }
178 });
179 }
180 @@ -75,13 +94,34 @@
181 public static final HeaderContributor getHeaderContribution(final Class<?> scope,
182 final String path, final String media)
183 {
184 + return getHeaderContribution(scope, path, media, false);
185 + }
186 +
187 + /**
188 + * Returns a new instance of {@link HeaderContributor} with a header contributor that references
189 + * a CSS file that lives in a package.
190 + *
191 + * @param scope
192 + * The scope of the package resource (typically the class of the caller, or a class
193 + * that lives in the package where the resource lives).
194 + * @param path
195 + * The path
196 + * @param media
197 + * The media type for this CSS ("print", "screen", etc.)
198 + * @param cacheBeforeRender
199 + * if true, the resource will be pre cached by the browser before it gets rendered (if cache is turned on)
200 + * @return the new header contributor instance
201 + */
202 + public static final HeaderContributor getHeaderContribution(final Class<?> scope,
203 + final String path, final String media, final boolean cacheBeforeRender)
204 + {
205 return new HeaderContributor(new IHeaderContributor()
206 {
207 private static final long serialVersionUID = 1L;
208
209 public void renderHead(IHeaderResponse response)
210 {
211 - response.renderCSSReference(new CompressedResourceReference(scope, path), media);
212 + response.renderCSSReference(new CompressedResourceReference(scope, path), media, cacheBeforeRender);
213 }
214 });
215 }
216 @@ -96,13 +136,28 @@
217 */
218 public static final HeaderContributor getHeaderContribution(final ResourceReference reference)
219 {
220 + return getHeaderContribution(reference, false);
221 + }
222 +
223 + /**
224 + * Returns a new instance of {@link HeaderContributor} with a header contributor that references
225 + * a CSS file that lives in a package.
226 + *
227 + * @param reference
228 + *
229 + * @param cacheBeforeRender
230 + * if true, the resource will be pre cached by the browser before it gets rendered (if cache is turned on)
231 + * @return the new header contributor instance
232 + */
233 + public static final HeaderContributor getHeaderContribution(final ResourceReference reference, final boolean cacheBeforeRender)
234 + {
235 return new HeaderContributor(new IHeaderContributor()
236 {
237 private static final long serialVersionUID = 1L;
238
239 public void renderHead(IHeaderResponse response)
240 {
241 - response.renderCSSReference(reference);
242 + response.renderCSSReference(reference, cacheBeforeRender);
243 }
244 });
245 }
246 @@ -119,13 +174,30 @@
247 public static final HeaderContributor getHeaderContribution(final ResourceReference reference,
248 final String media)
249 {
250 + return getHeaderContribution(reference, media, false);
251 + }
252 +
253 + /**
254 + * Returns a new instance of {@link HeaderContributor} with a header contributor that references
255 + * a CSS file that lives in a package.
256 + *
257 + * @param reference
258 + * @param media
259 + * The media type for this CSS ("print", "screen", etc.)
260 + * @param cacheBeforeRender
261 + * if true, the resource will be pre cached by the browser before it gets rendered (if cache is turned on)
262 + * @return the new header contributor instance
263 + */
264 + public static final HeaderContributor getHeaderContribution(final ResourceReference reference,
265 + final String media, final boolean cacheBeforeRender)
266 + {
267 return new HeaderContributor(new IHeaderContributor()
268 {
269 private static final long serialVersionUID = 1L;
270
271 public void renderHead(IHeaderResponse response)
272 {
273 - response.renderCSSReference(reference, media);
274 + response.renderCSSReference(reference, media, cacheBeforeRender);
275 }
276 });
277 }
278 Index: src/main/java/org/apache/wicket/markup/html/DecoratingHeaderResponse.java
279 ===================================================================
280 --- src/main/java/org/apache/wicket/markup/html/DecoratingHeaderResponse.java (revision 1031154)
281 +++ src/main/java/org/apache/wicket/markup/html/DecoratingHeaderResponse.java (revision )
282 @@ -101,7 +101,17 @@
283 realResponse.renderCSSReference(url, media);
284 }
285
286 + public void renderCSSReference(final ResourceReference reference, final boolean cacheBeforeRender)
287 + {
288 + realResponse.renderCSSReference(reference, cacheBeforeRender);
289 + }
290 +
291 + public void renderCSSReference(final ResourceReference reference, final String media, final boolean cacheBeforeRender)
292 + {
293 + realResponse.renderCSSReference(reference, media, cacheBeforeRender);
294 + }
295 +
296 - public void renderString(CharSequence string)
297 + public void renderString(CharSequence string)
298 {
299 realResponse.renderString(string);
300 }
301 Index: src/main/java/org/apache/wicket/markup/html/IHeaderResponse.java
302 ===================================================================
303 --- src/main/java/org/apache/wicket/markup/html/IHeaderResponse.java (revision 730127)
304 +++ src/main/java/org/apache/wicket/markup/html/IHeaderResponse.java (revision )
305 @@ -92,7 +92,17 @@
306
307 /**
308 * Writes a CSS reference, if the specified reference hasn't been rendered yet.
309 - *
310 + *
311 + * @param reference
312 + * resource reference pointing to the CSS resource
313 + * @param cacheBeforeRender
314 + * if true, the resource will be pre cached by the browser before it gets rendered (if cache is turned on)
315 + */
316 + public void renderCSSReference(ResourceReference reference, boolean cacheBeforeRender);
317 +
318 + /**
319 + * Writes a CSS reference, if the specified reference hasn't been rendered yet.
320 + *
321 * @param url
322 * url of the CSS resource
323 */
324 @@ -110,7 +120,19 @@
325
326 /**
327 * Writes a CSS reference, if the specified reference hasn't been rendered yet.
328 - *
329 + *
330 + * @param reference
331 + * resource reference pointing to the CSS resource
332 + * @param media
333 + * the media type for this CSS ("print", "screen", etc.)
334 + * @param cacheBeforeRender
335 + * if true, the resource will be pre cached by the browser before it gets rendered (if cache is turned on)
336 + */
337 + public void renderCSSReference(ResourceReference reference, String media, boolean cacheBeforeRender);
338 +
339 + /**
340 + * Writes a CSS reference, if the specified reference hasn't been rendered yet.
341 + *
342 * @param url
343 * url of the CSS resource
344 * @param media
345 Index: src/main/java/org/apache/wicket/ajax/wicket-ajax.js
346 ===================================================================
347 --- src/main/java/org/apache/wicket/ajax/wicket-ajax.js (revision 1085654)
348 +++ src/main/java/org/apache/wicket/ajax/wicket-ajax.js (revision )
349 @@ -1573,27 +1573,52 @@
350 },
351
352 // Process an external stylesheet element
353 - processLink: function(steps, node) {
354 + processLink: function(steps, node) {
355 steps.push(function(notify) {
356 // if the element is already in head, skip it
357 if (Wicket.Head.containsElement(node, "href")) {
358 notify();
359 return;
360 }
361 - // create link element
362 +
363 + var createLinkElement = function() {
364 - var css = Wicket.Head.createElement("link");
365 + var css = Wicket.Head.createElement("link");
366
367 - // copy required attributes
368 - css.id = node.getAttribute("id");
369 - css.rel = node.getAttribute("rel");
370 - css.href = node.getAttribute("href");
371 - css.type = node.getAttribute("type");
372 -
373 - // add element to head
374 - Wicket.Head.addElement(css);
375 -
376 - // continue to next step
377 - notify();
378 + // copy required attributes
379 + css.id = node.getAttribute("id");
380 + css.rel = node.getAttribute("rel");
381 + css.href = node.getAttribute("href");
382 + css.type = node.getAttribute("type");
383 +
384 + // add element to head
385 + Wicket.Head.addElement(css);
386 +
387 + // continue to next step
388 + notify();
389 + };
390 +
391 + // if the cacheBeforeRender attribute is present, we request the css to fill the browsers cache
392 + // so the chance is higher the css gets rendered before other contributions are loaded
393 + if (node.getAttribute("cacheBeforeRender")) {
394 + var seqNumber = (Wicket.Head.csspSequenceNumber++);
395 +
396 + // we need to schedule the request as timeout
397 + // calling xml http request from another request call stack doesn't work
398 + window.setTimeout(function() {
399 + var req = new Wicket.Ajax.Request(node.getAttribute('href'), function() {
400 + Wicket.Ajax.invokePostCallHandlers();
401 + createLinkElement();
402 + }, false, false);
403 + req.debugContent = false;
404 + if (Wicket.Browser.isKHTML())
405 + // konqueror can't process the ajax response asynchronously, therefore the
406 + // javascript loading must be also synchronous
407 + req.async = false;
408 + req.get();
409 + }, 1);
410 + } else {
411 + createLinkElement();
412 + }
413 });
414 },
415

Properties

Name Value
svn:mergeinfo /hippo-cms7/cms/branches/hippo-cms-2.18.xx/WICKET-3927_2.patch:25589-26171,26224,26239,26256,26452,26504,26526,26573,26778,26782,26913 /hippo-ecm/branches/Branch-HREPTWO-v2_16_xx/WICKET-3927_2.patch:24637