1 /*
2 * Angkor Web Framework
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */
7
8 package com.tirsen.angkor.jsp;
9
10 import com.tirsen.angkor.Debug;
11 import org.apache.log4j.Category;
12
13 import javax.servlet.jsp.JspException;
14 import javax.servlet.jsp.tagext.TagSupport;
15
16 /***
17 * Implementation of a tag that includes named components into a jsp-page, the components are
18 * fetched from the application instance created by the ApplicationFilter which must be mapped
19 * to all requests to jsp-pages using this tag.
20 * Also needs to be behind a PrerenderFilter now. TODO update this doc.
21 *
22 * <!-- $Id: ComponentTag.java,v 1.3 2002/10/09 21:37:37 tirsen Exp $ -->
23 *
24 * @author $Author: tirsen $
25 * @version $Revision: 1.3 $
26 */
27 public class ComponentTag extends TagSupport
28 {
29 private static final Category logger = Category.getInstance(Debug.LOGGER_NAME);
30
31 private String name;
32
33 public void setName(String name)
34 {
35 this.name = name;
36 }
37
38 public int doStartTag() throws JspException
39 {
40 return EVAL_BODY_INCLUDE;
41 }
42
43 public int doEndTag() throws JspException
44 {
45 PrerenderedComponentsRegistry registry = (PrerenderedComponentsRegistry)
46 pageContext.findAttribute(PrerenderFilter.REGISTRY_NAME);
47
48 /*
49 if(registry == null) registry = (PrerenderedComponentsRegistry)
50 pageContext.getRequest().getAttribute(PrerenderFilter.REGISTRY_NAME);
51 */
52
53 if (registry == null)
54 throw new JspException("No components prerendered. " +
55 "PrerenderFilter needs to filter this request.");
56
57 try
58 {
59 registry.render(name, pageContext.getOut());
60 }
61 catch (Exception e)
62 {
63 logger.error("error rendering prerendered view", e);
64 throw new JspException(e);
65 }
66 return super.doEndTag();
67 }
68 }
This page was automatically generated by Maven