forked from liferay/alloy-taglibs
/
tag_base.ftl
177 lines (147 loc) · 5.38 KB
/
tag_base.ftl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<#include "init.ftl">
<#include "copyright.ftl">
<#if component.isComponentTaglibOSGIModule() == true>
package ${packagePath}.taglib.base;
import ${packagePath}.ServletContextUtil;
<#else>
package ${packagePath}.${component.getPackage()}.base;
</#if>
<#if component.getWriteJSP() == true>
import javax.servlet.http.HttpServletRequest;
</#if>
import javax.servlet.jsp.JspException;
<#if component.isComponentTaglibOSGIModule() == true>
import javax.servlet.jsp.PageContext;
</#if>
/**
<#list component.getAuthors() as author>
* @author ${author}
</#list>
* @generated
*/
public abstract class Base${component.getClassName()} extends ${component.getParentClass()} {
<#if typeUtil.hasMethod(component.getParentClass(), "doStartTag", []) == true>
@Override
</#if>
public int doStartTag() throws JspException {
<#if typeUtil.hasMethod(component.getParentClass(), "setAttributeNamespace", ["java.lang.String"]) == true>
setAttributeNamespace(_ATTRIBUTE_NAMESPACE);
</#if>
return super.doStartTag();
}
<#list component.getAttributesAndEvents() as attribute>
<#if attribute.isGettable()>
<#if typeUtil.hasMethod(component.getParentClass(), "get" + attribute.getCapitalizedName(), []) == true>
@Override
</#if>
public ${attribute.getRawInputType()} get${attribute.getCapitalizedName()}() {
return _${attribute.getSafeName()};
}
</#if>
</#list>
<#list component.getAttributesAndEvents() as attribute>
<#if attribute.isSettable()>
<#if typeUtil.hasMethod(component.getParentClass(), "set" + attribute.getCapitalizedName(), [attribute.getRawInputType()]) == true>
@Override
</#if>
public void set${attribute.getCapitalizedName()}(${attribute.getRawInputType()} ${attribute.getSafeName()}) {
_${attribute.getSafeName()} = ${attribute.getSafeName()};
<#if typeUtil.hasMethod(component.getParentClass(), "setScopedAttribute", ["java.lang.String", "java.lang.Object"]) == true>
setScopedAttribute("${attribute.getSafeName()}", ${attribute.getSafeName()});
</#if>
}
</#if>
</#list>
<#if component.isComponentTaglibOSGIModule() == true>
<#if typeUtil.hasMethod(component.getParentClass(), "setPageContext", ["javax.servlet.jsp.PageContext"]) == true>
@Override
</#if>
public void setPageContext(PageContext pageContext) {
<#if typeUtil.hasMethod(component.getParentClass(), "setPageContext", ["javax.servlet.jsp.PageContext"]) == true>
super.setPageContext(pageContext);
</#if>
setServletContext(ServletContextUtil.getServletContext());
}
</#if>
<#if typeUtil.hasMethod(component.getParentClass(), "cleanUp", []) == true>
@Override
</#if>
protected void cleanUp() {
<#if typeUtil.hasMethod(component.getParentClass(), "cleanUp", []) == true>
super.cleanUp();
</#if>
<#list component.getAttributesAndEvents() as attribute>
<#compress>
<#assign outputSimpleClassName = attribute.getOutputTypeSimpleClassName()>
<#assign defaultValue = "">
<#if attribute.getDefaultValue()??>
<#assign defaultValue = attribute.getDefaultValue()>
</#if>
<#assign defaultValue = getCleanUpValue(outputSimpleClassName, defaultValue)>
</#compress>
<#if attribute.isGettable() || attribute.isSettable()>
_${attribute.getSafeName()} = ${defaultValue};
</#if>
</#list>
}
<#if component.isBodyContent() == true>
<#if typeUtil.hasMethod(component.getParentClass(), "getEndPage", []) == true>
@Override
</#if>
protected String getEndPage() {
return _END_PAGE;
}
<#if typeUtil.hasMethod(component.getParentClass(), "getStartPage", []) == true>
@Override
</#if>
protected String getStartPage() {
return _START_PAGE;
}
<#else>
<#if typeUtil.hasMethod(component.getParentClass(), "getPage", []) == true>
@Override
</#if>
protected String getPage() {
return _PAGE;
}
</#if>
<#if component.getWriteJSP() == true>
<#if typeUtil.hasMethod(component.getParentClass(), "setAttributes", ["javax.servlet.http.HttpServletRequest"]) == true>
@Override
</#if>
protected void setAttributes(HttpServletRequest request) {
<#list component.getAttributesAndEvents() as attribute>
<#if typeUtil.hasMethod(component.getParentClass(), "setNamespacedAttribute", ["javax.servlet.http.HttpServletRequest", "java.lang.String", "java.lang.Object"]) == true>
setNamespacedAttribute(request, "${attribute.getSafeName()}", _${attribute.getSafeName()});
<#else>
request.setAttribute("${attribute.getName()}", _${attribute.getSafeName()});
</#if>
</#list>
}
</#if>
<#if typeUtil.hasMethod(component.getParentClass(), "setNamespacedAttribute", ["javax.servlet.http.HttpServletRequest", "java.lang.String", "java.lang.Object"]) == true>
protected static final String _ATTRIBUTE_NAMESPACE = "${namespace}";
</#if>
<#if component.isBodyContent() == true>
private static final String _END_PAGE =
"${jspRelativePath}/end.jsp";
private static final String _START_PAGE =
"${jspRelativePath}/start.jsp";
<#else>
private static final String _PAGE =
"${jspRelativePath}/page.jsp";
</#if>
<#list component.getAttributesAndEvents() as attribute>
<#compress>
<#assign outputSimpleClassName = attribute.getOutputTypeSimpleClassName()>
<#assign defaultValue = "">
<#if attribute.getDefaultValue()??>
<#assign defaultValue = attribute.getDefaultValue()>
</#if>
<#assign defaultValue = getCleanUpValue(outputSimpleClassName, defaultValue)>
</#compress>
<#if attribute.isGettable() || attribute.isSettable()>
private ${attribute.getRawInputType()} _${attribute.getSafeName()} = ${defaultValue};
</#if>
</#list>
}