1
22
23 package com.liferay.taglib.util;
24
25 import com.liferay.portal.kernel.servlet.StringServletResponse;
26 import com.liferay.portal.kernel.util.HttpUtil;
27 import com.liferay.portal.model.Layout;
28 import com.liferay.taglib.portlet.ActionURLTag;
29 import com.liferay.taglib.portletext.IconBackTag;
30 import com.liferay.taglib.portletext.IconCloseTag;
31 import com.liferay.taglib.portletext.IconConfigurationTag;
32 import com.liferay.taglib.portletext.IconEditDefaultsTag;
33 import com.liferay.taglib.portletext.IconEditGuestTag;
34 import com.liferay.taglib.portletext.IconEditTag;
35 import com.liferay.taglib.portletext.IconHelpTag;
36 import com.liferay.taglib.portletext.IconMaximizeTag;
37 import com.liferay.taglib.portletext.IconMinimizeTag;
38 import com.liferay.taglib.portletext.IconPortletCssTag;
39 import com.liferay.taglib.portletext.IconPortletTag;
40 import com.liferay.taglib.portletext.IconPrintTag;
41 import com.liferay.taglib.portletext.IconRefreshTag;
42 import com.liferay.taglib.portletext.RuntimeTag;
43 import com.liferay.taglib.portletext.TitleTag;
44 import com.liferay.taglib.security.DoAsURLTag;
45 import com.liferay.taglib.security.PermissionsURLTag;
46 import com.liferay.taglib.theme.LayoutIconTag;
47 import com.liferay.taglib.theme.MetaTagsTag;
48 import com.liferay.taglib.theme.WrapPortletTag;
49 import com.liferay.taglib.ui.JournalContentSearchTag;
50 import com.liferay.taglib.ui.LanguageTag;
51 import com.liferay.taglib.ui.MyPlacesTag;
52 import com.liferay.taglib.ui.PngImageTag;
53 import com.liferay.taglib.ui.SearchTag;
54 import com.liferay.taglib.ui.StagingTag;
55 import com.liferay.taglib.ui.ToggleTag;
56
57 import java.util.Map;
58
59 import javax.portlet.PortletMode;
60 import javax.portlet.PortletRequest;
61 import javax.portlet.WindowState;
62
63 import javax.servlet.RequestDispatcher;
64 import javax.servlet.ServletContext;
65 import javax.servlet.http.HttpServletRequest;
66 import javax.servlet.jsp.PageContext;
67
68
74 public class VelocityTaglib {
75
76 public VelocityTaglib() {
77 }
78
79 public VelocityTaglib(
80 ServletContext ctx, HttpServletRequest req, StringServletResponse res,
81 PageContext pageContext) {
82
83 init(ctx, req, res, pageContext);
84 }
85
86 public VelocityTaglib init(
87 ServletContext ctx, HttpServletRequest req, StringServletResponse res,
88 PageContext pageContext) {
89
90 _ctx = ctx;
91 _req = req;
92 _res = res;
93 _pageContext = pageContext;
94
95 return this;
96 }
97
98 public String actionURL(String portletName, String queryString)
99 throws Exception {
100
101 String windowState = WindowState.NORMAL.toString();
102 String portletMode = PortletMode.VIEW.toString();
103
104 return actionURL(windowState, portletMode, portletName, queryString);
105 }
106
107 public String actionURL(
108 String windowState, String portletMode, String portletName,
109 String queryString)
110 throws Exception {
111
112 Boolean secure = null;
113 Boolean copyCurrentRenderParameters = null;
114 Boolean escapeXml = null;
115 String name = null;
116 Boolean anchor = null;
117 Boolean encrypt = null;
118 long doAsUserId = 0;
119 Boolean portletConfiguration = null;
120
121 return actionURL(
122 windowState, portletMode, secure, copyCurrentRenderParameters,
123 escapeXml, name, portletName, anchor, encrypt, doAsUserId,
124 portletConfiguration, queryString);
125 }
126
127 public String actionURL(
128 String windowState, String portletMode, Boolean secure,
129 Boolean copyCurrentRenderParameters, Boolean escapeXml, String name,
130 String portletName, Boolean anchor, Boolean encrypt,
131 long doAsUserId, Boolean portletConfiguration, String queryString)
132 throws Exception {
133
134 String var = null;
135 String varImpl = null;
136 String resourceID = null;
137 String cacheability = null;
138 Map<String, String[]> params = HttpUtil.parameterMapFromString(
139 queryString);
140 boolean writeOutput = false;
141
142 return ActionURLTag.doTag(
143 PortletRequest.ACTION_PHASE, windowState, portletMode, var, varImpl,
144 secure, copyCurrentRenderParameters, escapeXml, name, resourceID,
145 cacheability, portletName, anchor, encrypt, doAsUserId,
146 portletConfiguration, params, writeOutput, _pageContext);
147 }
148
149 public String doAsURL(long doAsUserId) throws Exception {
150 return DoAsURLTag.doTag(doAsUserId, null, false, _pageContext);
151 }
152
153 public String iconBack() throws Exception {
154 _res.recycle();
155
156 IconBackTag.doTag(_ctx, _req, _res);
157
158 return _res.getString();
159 }
160
161 public String iconBack(String page) throws Exception {
162 _res.recycle();
163
164 IconBackTag.doTag(page, _ctx, _req, _res);
165
166 return _res.getString();
167 }
168
169 public String iconClose() throws Exception {
170 _res.recycle();
171
172 IconCloseTag.doTag(_ctx, _req, _res);
173
174 return _res.getString();
175 }
176
177 public String iconClose(String page) throws Exception {
178 _res.recycle();
179
180 IconCloseTag.doTag(page, _ctx, _req, _res);
181
182 return _res.getString();
183 }
184
185 public String iconConfiguration() throws Exception {
186 _res.recycle();
187
188 IconConfigurationTag.doTag(_ctx, _req, _res);
189
190 return _res.getString();
191 }
192
193 public String iconConfiguration(String page) throws Exception {
194 _res.recycle();
195
196 IconConfigurationTag.doTag(page, _ctx, _req, _res);
197
198 return _res.getString();
199 }
200
201 public String iconEdit() throws Exception {
202 _res.recycle();
203
204 IconEditTag.doTag(_ctx, _req, _res);
205
206 return _res.getString();
207 }
208
209 public String iconEdit(String page) throws Exception {
210 _res.recycle();
211
212 IconEditTag.doTag(page, _ctx, _req, _res);
213
214 return _res.getString();
215 }
216
217 public String iconEditDefaults() throws Exception {
218 _res.recycle();
219
220 IconEditDefaultsTag.doTag(_ctx, _req, _res);
221
222 return _res.getString();
223 }
224
225 public String iconEditGuest() throws Exception {
226 _res.recycle();
227
228 IconEditGuestTag.doTag(_ctx, _req, _res);
229
230 return _res.getString();
231 }
232
233 public String iconEditGuest(String page) throws Exception {
234 _res.recycle();
235
236 IconEditGuestTag.doTag(page, _ctx, _req, _res);
237
238 return _res.getString();
239 }
240
241 public String iconHelp() throws Exception {
242 _res.recycle();
243
244 IconHelpTag.doTag(_ctx, _req, _res);
245
246 return _res.getString();
247 }
248
249 public String iconHelp(String page) throws Exception {
250 _res.recycle();
251
252 IconHelpTag.doTag(page, _ctx, _req, _res);
253
254 return _res.getString();
255 }
256
257 public String iconMaximize() throws Exception {
258 _res.recycle();
259
260 IconMaximizeTag.doTag(_ctx, _req, _res);
261
262 return _res.getString();
263 }
264
265 public String iconMaximize(String page) throws Exception {
266 _res.recycle();
267
268 IconMaximizeTag.doTag(page, _ctx, _req, _res);
269
270 return _res.getString();
271 }
272
273 public String iconMinimize() throws Exception {
274 _res.recycle();
275
276 IconMinimizeTag.doTag(_ctx, _req, _res);
277
278 return _res.getString();
279 }
280
281 public String iconMinimize(String page) throws Exception {
282 _res.recycle();
283
284 IconMinimizeTag.doTag(page, _ctx, _req, _res);
285
286 return _res.getString();
287 }
288
289 public String iconPortlet() throws Exception {
290 _res.recycle();
291
292 IconPortletTag.doTag(_ctx, _req, _res);
293
294 return _res.getString();
295 }
296
297 public String iconPortlet(String page) throws Exception {
298 _res.recycle();
299
300 IconPortletTag.doTag(page, _ctx, _req, _res);
301
302 return _res.getString();
303 }
304
305 public String iconPortletCss() throws Exception {
306 _res.recycle();
307
308 IconPortletCssTag.doTag(_ctx, _req, _res);
309
310 return _res.getString();
311 }
312
313 public String iconPortletCss(String page) throws Exception {
314 _res.recycle();
315
316 IconPortletCssTag.doTag(page, _ctx, _req, _res);
317
318 return _res.getString();
319 }
320
321 public String iconPrint() throws Exception {
322 _res.recycle();
323
324 IconPrintTag.doTag(_ctx, _req, _res);
325
326 return _res.getString();
327 }
328
329 public String iconPrint(String page) throws Exception {
330 _res.recycle();
331
332 IconPrintTag.doTag(page, _ctx, _req, _res);
333
334 return _res.getString();
335 }
336
337 public String iconRefresh() throws Exception {
338 _res.recycle();
339
340 IconRefreshTag.doTag(_ctx, _req, _res);
341
342 return _res.getString();
343 }
344
345 public String iconRefresh(String page) throws Exception {
346 _res.recycle();
347
348 IconRefreshTag.doTag(page, _ctx, _req, _res);
349
350 return _res.getString();
351 }
352
353 public String include(String page) throws Exception {
354 _res.recycle();
355
356 RequestDispatcher rd = _ctx.getRequestDispatcher(page);
357
358 rd.include(_req, _res);
359
360 return _res.getString();
361 }
362
363 public String journalContentSearch() throws Exception {
364 _res.recycle();
365
366 JournalContentSearchTag.doTag(_ctx, _req, _res);
367
368 return _res.getString();
369 }
370
371 public String language() throws Exception {
372 _res.recycle();
373
374 LanguageTag.doTag(_ctx, _req, _res);
375
376 return _res.getString();
377 }
378
379 public String language(
380 String formName, String formAction, String name, int displayStyle)
381 throws Exception {
382
383 _res.recycle();
384
385 LanguageTag.doTag(
386 formName, formAction, name, null, displayStyle, _ctx, _req, _res);
387
388 return _res.getString();
389 }
390
391 public String language(
392 String formName, String formAction, String name,
393 String[] languageIds, int displayStyle)
394 throws Exception {
395
396 _res.recycle();
397
398 LanguageTag.doTag(
399 formName, formAction, name, languageIds, displayStyle, _ctx, _req,
400 _res);
401
402 return _res.getString();
403 }
404
405 public String language(
406 String page, String formName, String formAction, String name,
407 int displayStyle)
408 throws Exception {
409
410 _res.recycle();
411
412 LanguageTag.doTag(
413 page, formName, formAction, name, null, displayStyle, _ctx, _req,
414 _res);
415
416 return _res.getString();
417 }
418
419 public String language(
420 String page, String formName, String formAction, String name,
421 String[] languageIds, int displayStyle)
422 throws Exception {
423
424 _res.recycle();
425
426 LanguageTag.doTag(
427 page, formName, formAction, name, languageIds, displayStyle, _ctx,
428 _req, _res);
429
430 return _res.getString();
431 }
432
433 public String layoutIcon(Layout layout) throws Exception {
434 _res.recycle();
435
436 LayoutIconTag.doTag(layout, _ctx, _req, _res);
437
438 return _res.getString();
439 }
440
441 public String metaTags() throws Exception {
442 _res.recycle();
443
444 MetaTagsTag.doTag(_ctx, _req, _res);
445
446 return _res.getString();
447 }
448
449 public String myPlaces() throws Exception {
450 _res.recycle();
451
452 MyPlacesTag.doTag(_ctx, _req, _res);
453
454 return _res.getString();
455 }
456
457 public String permissionsURL(
458 String redirect, String modelResource,
459 String modelResourceDescription, String resourcePrimKey)
460 throws Exception {
461
462 return PermissionsURLTag.doTag(
463 redirect, modelResource, modelResourceDescription, resourcePrimKey,
464 null, false, _pageContext);
465 }
466
467 public String pngImage(String image, String height, String width)
468 throws Exception {
469
470 _res.recycle();
471
472 PngImageTag.doTag(image, height, width, _ctx, _req, _res);
473
474 return _res.getString();
475 }
476
477 public String renderURL(String portletName, String queryString)
478 throws Exception {
479
480 String windowState = WindowState.NORMAL.toString();
481 String portletMode = PortletMode.VIEW.toString();
482
483 return renderURL(windowState, portletMode, portletName, queryString);
484 }
485
486 public String renderURL(
487 String windowState, String portletMode, String portletName,
488 String queryString)
489 throws Exception {
490
491 Boolean secure = null;
492 Boolean copyCurrentRenderParameters = null;
493 Boolean escapeXml = null;
494 Boolean anchor = null;
495 Boolean encrypt = null;
496 long doAsUserId = 0;
497 Boolean portletConfiguration = null;
498
499 return renderURL(
500 windowState, portletMode, secure, copyCurrentRenderParameters,
501 escapeXml, portletName, anchor, encrypt, doAsUserId,
502 portletConfiguration, queryString);
503 }
504
505 public String renderURL(
506 String windowState, String portletMode, Boolean secure,
507 Boolean copyCurrentRenderParameters, Boolean escapeXml,
508 String portletName, Boolean anchor, Boolean encrypt,
509 long doAsUserId, Boolean portletConfiguration, String queryString)
510 throws Exception {
511
512 String var = null;
513 String varImpl = null;
514 String name = null;
515 String resourceID = null;
516 String cacheability = null;
517 Map<String, String[]> params = HttpUtil.parameterMapFromString(
518 queryString);
519 boolean writeOutput = false;
520
521 return ActionURLTag.doTag(
522 PortletRequest.RENDER_PHASE, windowState, portletMode, var, varImpl,
523 secure, copyCurrentRenderParameters, escapeXml, name, resourceID,
524 cacheability, portletName, anchor, encrypt, doAsUserId,
525 portletConfiguration, params, writeOutput, _pageContext);
526 }
527
528 public String runtime(String portletName)
529 throws Exception {
530
531 return runtime(portletName, null);
532 }
533
534 public String runtime(String portletName, String queryString)
535 throws Exception {
536
537 _res.recycle();
538
539 RuntimeTag.doTag(portletName, queryString, null, _ctx, _req, _res);
540
541 return _res.getString();
542 }
543
544 public String runtime(
545 String portletName, String queryString, String defaultPreferences)
546 throws Exception {
547
548 _res.recycle();
549
550 RuntimeTag.doTag(
551 portletName, queryString, defaultPreferences, null, _ctx, _req,
552 _res);
553
554 return _res.getString();
555 }
556
557 public String search() throws Exception {
558 _res.recycle();
559
560 SearchTag.doTag(_ctx, _req, _res);
561
562 return _res.getString();
563 }
564
565 public String staging() throws Exception {
566 _res.recycle();
567
568 StagingTag.doTag(_ctx, _req, _res);
569
570 return _res.getString();
571 }
572
573 public String title() throws Exception {
574 _res.recycle();
575
576 TitleTag.doTag(_ctx, _req, _res);
577
578 return _res.getString();
579 }
580
581 public String title(boolean editable) throws Exception {
582 _res.recycle();
583
584 TitleTag.doTag(editable, _ctx, _req, _res);
585
586 return _res.getString();
587 }
588
589 public String toggle(
590 String id, String showImage, String hideImage, String showMessage,
591 String hideMessage, boolean defaultShowContent)
592 throws Exception {
593
594 _res.recycle();
595
596 ToggleTag.doTag(
597 id, showImage, hideImage, showMessage, hideMessage,
598 defaultShowContent, null, _ctx, _req, _res);
599
600 return _res.getString();
601 }
602
603 public String wrapPortlet(String wrapPage, String portletPage)
604 throws Exception {
605
606 _res.recycle();
607
608 return WrapPortletTag.doTag(
609 wrapPage, portletPage, _ctx, _req, _res, _pageContext);
610 }
611
612 private ServletContext _ctx;
613 private HttpServletRequest _req;
614 private StringServletResponse _res;
615 private PageContext _pageContext;
616
617 }