Source code: com/obinary/cms/taglibs/LoadPage.java
1 /**
2 *
3 * Magnolia and its source-code is licensed under the LGPL.
4 * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5 * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6 * you are required to provide proper attribution to obinary.
7 * If you reproduce or distribute the document without making any substantive modifications to its content,
8 * please use the following attribution line:
9 *
10 * Copyright 1993-2003 obinary Ltd. (http://www.obinary.com) All rights reserved.
11 *
12 * */
13
14
15
16
17
18 package com.obinary.cms.taglibs;
19
20 import com.obinary.cms.Aggregator;
21 import com.obinary.cms.util.Resource;
22 import com.obinary.cms.core.Content;
23 import com.obinary.cms.core.HierarchyManager;
24
25 import javax.servlet.jsp.tagext.BodyTagSupport;
26 import javax.servlet.jsp.PageContext;
27 import javax.servlet.http.HttpServletRequest;
28
29
30 /**
31 * Date: Apr 28, 2003
32 * Time: 11:20:59 AM
33 * @author Marcel Salathe
34 * @version 1.0
35 */
36
37
38
39 public class LoadPage extends BodyTagSupport {
40
41
42 private String path = "";
43 private String templateName = "";
44 private int level = 0;
45
46 public int doEndTag() {
47 HttpServletRequest req = (HttpServletRequest)pageContext.getRequest();
48 Content newActpage = Resource.getCurrentActivePage(req);
49 if (!this.templateName.equals("")) {
50 Content startPage;
51 try {
52 startPage = Resource.getCurrentActivePage(req).getAncestor(this.level);
53 HierarchyManager hm = Resource.getHierarchyManager(req);
54 newActpage = hm.getPage(startPage.getHandle(),this.templateName);
55
56 }
57 catch (Exception e) {
58 e.printStackTrace();
59 return SKIP_BODY;
60 }
61 }
62 if (!this.path.equals("")) {
63 try {
64 newActpage = Resource.getHierarchyManager(req).getPage(this.path);
65 }
66 catch (Exception e) {
67 return SKIP_BODY;
68 }
69 }
70 pageContext.setAttribute(Aggregator.CURRENT_ACTPAGE,newActpage,PageContext.REQUEST_SCOPE);
71 return EVAL_BODY_INCLUDE;
72 }
73
74
75 public void setPath(String path) {
76 this.path = path;
77 }
78
79 public void setTemplateName(String templateName) {
80 this.templateName = templateName;
81 }
82
83 public void setLevel(String level) {
84 this.level = (new Integer(level)).intValue();
85 }
86
87
88 }