View Javadoc

1   /*
2    * This file was automatically generated by Apache Tiles Autotag.
3    */
4   package org.apache.tiles.jsp.taglib;
5   
6   import java.io.IOException;
7   
8   import javax.servlet.jsp.JspException;
9   import javax.servlet.jsp.tagext.SimpleTagSupport;
10  
11  import org.apache.tiles.autotag.core.runtime.ModelBody;
12  import org.apache.tiles.autotag.core.runtime.AutotagRuntime;
13  
14  /**
15   * <p>
16   * <strong>Create a definition at runtime. </strong>
17   * </p>
18   * <p>
19   * Create a new definition at runtime. Newly created definition will be
20   * available across the entire request.
21   * </p>
22   */
23  public class DefinitionTag extends SimpleTagSupport {
24  
25      /**
26       * The template model.
27       */
28      private org.apache.tiles.template.DefinitionModel model = new org.apache.tiles.template.DefinitionModel();
29  
30      /**
31       * The name of the definition to create. If not specified, an
32       * anonymous definition will be created.
33       */
34      private java.lang.String name;
35  
36      /**
37       * The template of this definition.
38       */
39      private java.lang.String template;
40  
41      /**
42       * A comma-separated list of roles. If present, the definition
43       * will be rendered only if the current user belongs to one of the roles.
44       */
45      private java.lang.String role;
46  
47      /**
48       * The definition name that this definition extends.
49       */
50      private java.lang.String extendsParam;
51  
52      /**
53       * The preparer to use to invoke before the definition is
54       * rendered.
55       */
56      private java.lang.String preparer;
57  
58      /**
59       * Getter for name property.
60       *
61       * @return
62       * The name of the definition to create. If not specified, an
63       * anonymous definition will be created.
64       */
65      public java.lang.String getName() {
66          return name;
67      }
68  
69      /**
70       * Setter for name property.
71       *
72       * @param name
73       * The name of the definition to create. If not specified, an
74       * anonymous definition will be created.
75       */
76      public void setName(java.lang.String name) {
77          this.name = name;
78      }
79  
80      /**
81       * Getter for template property.
82       *
83       * @return
84       * The template of this definition.
85       */
86      public java.lang.String getTemplate() {
87          return template;
88      }
89  
90      /**
91       * Setter for template property.
92       *
93       * @param template
94       * The template of this definition.
95       */
96      public void setTemplate(java.lang.String template) {
97          this.template = template;
98      }
99  
100     /**
101      * Getter for role property.
102      *
103      * @return
104      * A comma-separated list of roles. If present, the definition
105      * will be rendered only if the current user belongs to one of the roles.
106      */
107     public java.lang.String getRole() {
108         return role;
109     }
110 
111     /**
112      * Setter for role property.
113      *
114      * @param role
115      * A comma-separated list of roles. If present, the definition
116      * will be rendered only if the current user belongs to one of the roles.
117      */
118     public void setRole(java.lang.String role) {
119         this.role = role;
120     }
121 
122     /**
123      * Getter for extends property.
124      *
125      * @return
126      * The definition name that this definition extends.
127      */
128     public java.lang.String getExtends() {
129         return extendsParam;
130     }
131 
132     /**
133      * Setter for extends property.
134      *
135      * @param extendsParam
136      * The definition name that this definition extends.
137      */
138     public void setExtends(java.lang.String extendsParam) {
139         this.extendsParam = extendsParam;
140     }
141 
142     /**
143      * Getter for preparer property.
144      *
145      * @return
146      * The preparer to use to invoke before the definition is
147      * rendered.
148      */
149     public java.lang.String getPreparer() {
150         return preparer;
151     }
152 
153     /**
154      * Setter for preparer property.
155      *
156      * @param preparer
157      * The preparer to use to invoke before the definition is
158      * rendered.
159      */
160     public void setPreparer(java.lang.String preparer) {
161         this.preparer = preparer;
162     }
163 
164     /** {@inheritDoc} */
165     @Override
166     public void doTag() throws JspException, IOException {
167         AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.jsp.autotag.JspAutotagRuntime();
168         if (runtime instanceof SimpleTagSupport) {
169             SimpleTagSupport tag = (SimpleTagSupport) runtime;
170             tag.setJspContext(getJspContext());
171             tag.setJspBody(getJspBody());
172             tag.setParent(getParent());
173             tag.doTag();
174         }
175         org.apache.tiles.request.Request request = runtime.createRequest();        
176         ModelBody modelBody = runtime.createModelBody();
177         model.execute(
178             name,
179             template,
180             role,
181             extendsParam,
182             preparer,
183             request, modelBody
184         );
185     }
186 }