This repository has been archived by the owner on Apr 8, 2019. It is now read-only.
/
UIFormWithTitle.gtmpl
77 lines (76 loc) · 3.1 KB
/
UIFormWithTitle.gtmpl
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
<%
import org.exoplatform.webui.form.UIFormInputBase;
import org.exoplatform.web.application.JavascriptManager;
def rcontext = _ctx.getRequestContext();
JavascriptManager jsManager = rcontext.getJavascriptManager();
jsManager.require("SHARED/uiForm");
String fieldName; %>
<div class="UIFormWithTitle $uicomponent.id" onkeypress="javascript:SubmitAction.call(this, event);">
<div class="TitleBar"><%=_ctx.appRes(uicomponent.getName() + ".title")%></div>
<% uiform.begin() %>
<div class="HorizontalLayout">
<div class="FormContainer">
<table class="UIFormGrid" summary="Component $uicomponent.id">
<%
boolean required = false;
for (field in uiform.getChildren()) {
if (!required && field instanceof UIFormInputBase) {
required = ((UIFormInputBase) field).isMandatory();
}
}
if (required) {
%>
<tr><td colspan=\"2\" style=\"text-align: right;\">Required field (*)</td></tr>
<%
}
for(field in uiform.getChildren()) {
if(field.isRendered()) {
%>
<tr>
<%fieldName = uicomponent.getLabel(field.getName());%>
<%if(field instanceof UIFormInputBase && !fieldName.equals(uicomponent.getId())) { %>
<td class="FieldLabel portlet-form-label" scope="row">
<%if(fieldName != null && fieldName.length() > 0) {%>
<label for="<%= field.getName() %>"><%=uicomponent.getLabel(field.getName()) %></label>
<%}%>
</td>
<% if(field instanceof UIFormInputBase && field.isEditable()) { %>
<td class="FieldComponent portlet-input-field"><% uiform.renderField(field) %></td>
<% }else { %>
<td class="NonEditableField portlet-input-field"><% uiform.renderField(field) %></td>
<% } %>
<%} else {%>
<td class="FieldComponent" colspan="2"><% uiform.renderField(field) %></td>
<%}%>
</tr>
<%
}
}
%>
</table>
<%//Rerender this component with the new structure%>
<%// start render action%>
<div class="UIAction">
<% for(action in uicomponent.getActions()) {
String actionLabel = _ctx.appRes(uicomponent.getName() + ".action." + action)
String link = uicomponent.event(action);
%>
<a href="javascript:window.scroll(0,0);" onclick="$link" class="ActionButton LightBlueStyle">$actionLabel</a>
<%}%>
</div>
<%// end render action%>
</div>
</div>
<%uiform.end()%>
</div>
<script language="javascript">
function SubmitAction(event) {
var event = window.event || event;
var code;
if(event.keyCode) code = event.keyCode;
else if (event.which) code = event.which;
if(code ==13) {
this.onsubmit = function(){ return false; }
}
}
</script>