Skip to content

Commit 3551a41

Browse files
committed
Feature #10785
Replace Java code by JSTL statements
1 parent 3dc566d commit 3551a41

File tree

1 file changed

+133
-109
lines changed
  • core-war/src/main/webapp/jobStartPagePeas/jsp

1 file changed

+133
-109
lines changed

core-war/src/main/webapp/jobStartPagePeas/jsp/bin.jsp

Lines changed: 133 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323
along with this program. If not, see <https://www.gnu.org/licenses/>.
2424
2525
--%>
26-
<%@ page import="org.silverpeas.core.admin.component.model.ComponentInstLight" %>
27-
<%@ page import="org.silverpeas.core.admin.space.SpaceInstLight" %>
28-
<%@ page import="org.silverpeas.core.util.WebEncodeHelper" %>
29-
3026
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
27+
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
3128
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
29+
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
3230
<%@ taglib uri="http://www.silverpeas.com/tld/silverFunctions" prefix="silfn" %>
3331
<%@ taglib uri="http://www.silverpeas.com/tld/viewGenerator" prefix="view"%>
3432
<%@ include file="check.jsp" %>
@@ -39,37 +37,42 @@
3937
<view:setBundle bundle="${requestScope.resources.multilangBundle}" />
4038
<view:setBundle bundle="${requestScope.resources.iconsBundle}" var="icons" />
4139

42-
<fmt:message key="JSPP.BinDeleteConfirm" var="BinDeleteConfirm"/>
43-
<fmt:message key="JSPP.BinDeleteConfirmSelected" var="BinDeleteConfirmSelected"/>
44-
<fmt:message key="JSPP.BinRestoreSelected" var="BinRestoreSelected"/>
45-
<fmt:message key="JSPP.BinAfterRestoreAskNavSpace" var="BinAfterRestoreAskNavSpace"/>
46-
<fmt:message key="JSPP.BinAfterRestoreAskNavComponent" var="BinAfterRestoreAskNavComponent"/>
47-
48-
<%
49-
List removedSpaces = (List) request.getAttribute("Spaces");
50-
List removedComponents = (List) request.getAttribute("Components");
51-
52-
operationPane.addOperation(resource.getIcon("JSPP.restoreAll"),resource.getString("JSPP.BinRestore"),"javascript:onClick=restore()");
53-
operationPane.addOperation(resource.getIcon("JSPP.deleteAll"),resource.getString("JSPP.BinDelete"),"javascript:onClick=remove()");
40+
<fmt:message key="JSPP.Bin" var="binTitle"/>
41+
<fmt:message key="JSPP.BinRestore" var="binRestoreOp"/>
42+
<fmt:message key="JSPP.BinDelete" var="binDeleteOp"/>
43+
<fmt:message key="JSPP.BinDeleteConfirm" var="binDeleteConfirm"/>
44+
<fmt:message key="JSPP.BinDeleteConfirmSelected" var="binDeleteConfirmSelected"/>
45+
<fmt:message key="JSPP.BinRestoreSelected" var="binRestoreSelected"/>
46+
<fmt:message key="JSPP.BinAfterRestoreAskNavSpace" var="binAfterRestoreAskNavSpace"/>
47+
<fmt:message key="JSPP.BinAfterRestoreAskNavComponent" var="binAfterRestoreAskNavComponent"/>
5448

55-
browseBar.setComponentName(resource.getString("JSPP.Bin"));
49+
<fmt:message key="JSPP.restoreAll" var="binRestoreAllIcon" bundle="${icons}"/>
50+
<c:url var="binRestoreAllIcon" value="${binRestoreAllIcon}"/>
51+
<fmt:message key="JSPP.deleteAll" var="binDeleteAllIcon" bundle="${icons}"/>
52+
<c:url var="binDeleteAllIcon" value="${binDeleteAllIcon}"/>
53+
<fmt:message key="JSPP.restore" var="binRestoreIcom" bundle="${icons}"/>
54+
<c:url var="binRestoreIcom" value="${binRestoreIcom}"/>
55+
<fmt:message key="JSPP.delete" var="binDeleteIcon" bundle="${icons}"/>
56+
<c:url var="binDeleteIcon" value="${binDeleteIcon}"/>
5657

57-
boolean emptyBin = true;
58-
%>
58+
<c:set var="removedSpaces" value="${requestScope.Spaces}"/>
59+
<c:set var="removedComponents" value="${requestScope.Components}"/>
60+
<c:set var="emptyBin"
61+
value="${fn:length(removedSpaces) == 0 && fn:length(removedComponents) == 0}"/>
5962

6063
<view:sp-page>
6164
<view:sp-head-part withCheckFormScript="true">
6265
<view:includePlugin name="qtip"/>
6366
<view:includePlugin name="popup"/>
6467
<script type="text/javascript">
6568
function removeItem(id) {
66-
jQuery.popup.confirm("${silfn:escapeJs(BinDeleteConfirm)}", function() {
69+
sp.popup.confirm("${silfn:escapeJs(binDeleteConfirm)}", function() {
6770
performRemove({'ItemId' : id});
6871
});
6972
}
7073
7174
function remove() {
72-
jQuery.popup.confirm("${silfn:escapeJs(BinDeleteConfirmSelected)}", function() {
75+
sp.popup.confirm("${silfn:escapeJs(binDeleteConfirmSelected)}", function() {
7376
performRemove(sp.form.serializeJson(document.forms.binForm));
7477
});
7578
}
@@ -88,7 +91,7 @@ function restoreItem(id) {
8891
}
8992
9093
function restore() {
91-
jQuery.popup.confirm("${silfn:escapeJs(BinRestoreSelected)}", function() {
94+
sp.popup.confirm("${silfn:escapeJs(binRestoreSelected)}", function() {
9295
performRestore(sp.form.serializeJson(document.forms.binForm));
9396
});
9497
}
@@ -102,19 +105,19 @@ function performRestore(params) {
102105
.then(function (restoreContext) {
103106
const action = {};
104107
if (restoreContext.spaceIds.length === 1 && restoreContext.componentIds.length === 0) {
105-
action.confirmMsg = "${silfn:escapeJs(BinAfterRestoreAskNavSpace)}";
108+
action.confirmMsg = "${silfn:escapeJs(binAfterRestoreAskNavSpace)}";
106109
action.execute = function() {
107110
spAdminWindow.loadSpace(restoreContext.spaceIds[0]);
108111
}
109112
} else if (restoreContext.spaceIds.length === 0 && restoreContext.componentIds.length === 1) {
110-
action.confirmMsg = "${silfn:escapeJs(BinAfterRestoreAskNavComponent)}";
113+
action.confirmMsg = "${silfn:escapeJs(binAfterRestoreAskNavComponent)}";
111114
action.execute = function() {
112115
spAdminWindow.loadComponent(restoreContext.componentIds[0]);
113116
}
114117
}
115118
if (action.confirmMsg) {
116119
spProgressMessage.hide();
117-
jQuery.popup.confirm(action.confirmMsg, {
120+
sp.popup.confirm(action.confirmMsg, {
118121
forceTitle : '',
119122
callback : action.execute,
120123
alternativeCallback : smoothReload,
@@ -134,18 +137,17 @@ function smoothReload() {
134137
}, spProgressMessage.hide)
135138
}
136139
137-
function jqCheckAll2(id, name)
138-
{
140+
function jqCheckAll2(id, name) {
139141
$("input[name='" + name + "'][type='checkbox']").attr('checked', $('#' + id).is(':checked'));
140142
}
141143
142144
$(document).ready(function() {
143-
// By suppling no content attribute, the library uses each elements title attribute by default
145+
// By supplying no content attribute, the library uses each elements title attribute by default
144146
$('.item-path').qtip({
145147
content : {
146148
text : false,
147149
title : {
148-
text : "<%=resource.getString("GML.path")%>"
150+
text : '<fmt:message key="GML.path"/>'
149151
}
150152
},
151153
style : {
@@ -165,94 +167,116 @@ $(document).ready(function() {
165167
</script>
166168
</view:sp-head-part>
167169
<view:sp-body-part cssClass="page_content_admin">
168-
<%
169-
out.println(window.printBefore());
170-
out.println(frame.printBefore());
171-
%>
170+
<view:browseBar componentId="${binTitle}"/>
171+
<view:operationPane>
172+
<view:operation action="javascript:restore()" altText="${binRestoreOp}"
173+
icon="${binRestoreAllIcon}"/>
174+
<view:operation action="javascript:remove()" altText="${binDeleteOp}" icon="${binDeleteAllIcon}"/>
175+
</view:operationPane>
176+
<view:window>
177+
<view:frame>
178+
172179
<div id="binContainer">
173180
<form name="binForm" action="" method="post">
174-
<%
175-
ArrayPane arrayPane = gef.getArrayPane("binContentSpaces", "ViewBin", request, session);
176-
arrayPane.addArrayColumn(resource.getString("GML.space"));
177-
arrayPane.addArrayColumn(resource.getString("JSPP.BinRemoveDate"));
178-
ArrayColumn columnOp = arrayPane.addArrayColumn("<span style=\"float:left\">"+resource.getString("GML.operation")+"</span> <input type=\"checkbox\" id=\"checkAllSpaces\" onclick=\"jqCheckAll2(this.id, 'SpaceIds')\" style=\"float:left;margin:0px;margin-left:5px;padding:0px;vertical-align:middle;background-color:none;\"/>");
179-
columnOp.setSortable(false);
180-
181-
//Array of deleted spaces
182-
if (removedSpaces != null && removedSpaces.size() != 0)
183-
{
184-
emptyBin = false;
185-
Iterator it = (Iterator) removedSpaces.iterator();
186-
while (it.hasNext())
187-
{
188-
ArrayLine line = arrayPane.addArrayLine();
189-
SpaceInstLight space = (SpaceInstLight) it.next();
190-
ArrayCellText cellLabel = null;
191-
if (space.isRoot())
192-
cellLabel = line.addArrayCellText(space.getName());
193-
else
194-
cellLabel = line.addArrayCellText("<a href=\"#\" class=\"item-path\" title=\""+
195-
WebEncodeHelper.javaStringToJsString(space.getPath(" > "))+"\"/>"+WebEncodeHelper.javaStringToHtmlString(space.getName())+"</a>");
196-
cellLabel.setCompareOn(space.getName());
197-
ArrayCellText cell = line.addArrayCellText(resource.getOutputDateAndHour(space.getRemovalDate())+"&nbsp;("+space.getRemoverName()+")");
198-
cell.setCompareOn(space.getRemovalDate());
199181

200-
IconPane iconPane = gef.getIconPane();
201-
Icon restoreIcon = iconPane.addIcon();
202-
restoreIcon.setProperties(resource.getIcon("JSPP.restore"), resource.getString("JSPP.BinRestore"), "javaScript:onclick=restoreItem('"+space.getId()+"')");
203-
Icon deleteIcon = iconPane.addIcon();
204-
deleteIcon.setProperties(resource.getIcon("JSPP.delete"), resource.getString("JSPP.BinDelete"), "javaScript:onClick=removeItem('"+space.getId()+"')");
205-
line.addArrayCellText(restoreIcon.print()+"&nbsp;&nbsp;&nbsp;"+deleteIcon.print()+"&nbsp;&nbsp;&nbsp;<input type=\"checkbox\" name=\"SpaceIds\" value=\""+space.getId()+"\">");
206-
}
207-
out.println(arrayPane.print());
208-
}
182+
<c:choose>
209183

210-
//Array of deleted components
211-
arrayPane = gef.getArrayPane("binContentComponents", "ViewBin", request, session);
212-
arrayPane.addArrayColumn(resource.getString("GML.component"));
213-
arrayPane.addArrayColumn(resource.getString("JSPP.BinRemoveDate"));
214-
columnOp = arrayPane.addArrayColumn("<span style=\"float:left\">"+resource.getString("GML.operation")+"</span> <input type=\"checkbox\" id=\"checkAllComponents\" onclick=\"jqCheckAll2(this.id, 'ComponentIds')\" style=\"float:left;margin:0px;margin-left:5px;padding:0px;vertical-align:middle;background-color:none;\"/>");
215-
columnOp.setSortable(false);
184+
<c:when test="${emptyBin}">
185+
<view:board>
186+
<div class="inlineMessage"><fmt:message key="JSPP.BinEmpty"/></div>
187+
</view:board>
188+
</c:when>
216189

217-
if (removedComponents != null && removedComponents.size() != 0)
218-
{
219-
if (!emptyBin)
220-
out.println("<br/>");
221-
222-
emptyBin = false;
223-
Iterator it = (Iterator) removedComponents.iterator();
224-
while (it.hasNext())
225-
{
226-
ArrayLine line = arrayPane.addArrayLine();
227-
ComponentInstLight component = (ComponentInstLight) it.next();
228-
line.addArrayCellText("<a href=\"#\" class=\"item-path\" title=\""+component.getPath(" > ")+"\"/>"+
229-
WebEncodeHelper.javaStringToHtmlString(component.getLabel())+"</a>");
230-
ArrayCellText cell = line.addArrayCellText(resource.getOutputDateAndHour(component.getRemovalDate())+"&nbsp;("+component.getRemoverName()+")");
231-
cell.setCompareOn(component.getRemovalDate());
232-
233-
IconPane iconPane = gef.getIconPane();
234-
Icon restoreIcon = iconPane.addIcon();
235-
restoreIcon.setProperties(resource.getIcon("JSPP.restore"), resource.getString("JSPP.BinRestore"), "javaScript:onclick=restoreItem('"+component.getId()+"')");
236-
Icon deleteIcon = iconPane.addIcon();
237-
deleteIcon.setProperties(resource.getIcon("JSPP.delete"), resource.getString("JSPP.BinDelete"), "javaScript:onClick=removeItem('"+component.getId()+"')");
238-
line.addArrayCellText(restoreIcon.print()+"&nbsp;&nbsp;&nbsp;"+deleteIcon.print()+"&nbsp;&nbsp;&nbsp;<input type=\"checkbox\" name=\"ComponentIds\" value=\""+component.getId()+"\">");
239-
}
240-
out.println(arrayPane.print());
241-
}
190+
<c:otherwise>
191+
<fmt:message key="JSPP.BinRemoveDate" var="deletionDateLabel"/>
192+
<fmt:message key="GML.operation" var="operationsLabel"/>
193+
<c:if test="${fn:length(removedSpaces) > 0}">
194+
<div id="removedSpaces" style="margin-bottom: 1em;">
195+
<fmt:message key="GML.spaces" var="spaceLabel"/>
196+
<c:set var="checkOp">
197+
<span style="float:left">${operationsLabel}</span>
198+
<input type="checkbox" id="checkAllSpaces"
199+
onkeydown="jqCheckAll2(this.id, 'SpaceIds')"
200+
onclick="jqCheckAll2(this.id, 'SpaceIds')"
201+
style="float:left;margin-left:5px;padding:0;background-color:unset;"/>
202+
</c:set>
203+
<view:arrayPane var="binContentSpaces" routingAddress="ViewBin">
204+
<view:arrayColumn title="${spaceLabel}" sortable="true"/>
205+
<view:arrayColumn title="${deletionDateLabel}" sortable="true"/>
206+
<view:arrayColumn title="${checkOp}" sortable="false"/>
207+
<view:arrayLines var="space" items="${removedSpaces}">
208+
<jsp:useBean id="space" type="org.silverpeas.core.admin.space.SpaceInstLight"/>
209+
<view:arrayLine>
210+
<c:choose>
211+
<c:when test="${space.root}">
212+
<view:arrayCellText text="${silfn:escapeHtml(space.getName(language))}"
213+
compareOn="${space.getName(language)}"/>
214+
</c:when>
215+
<c:otherwise>
216+
<view:arrayCellText compareOn="${space.getName(language)}">
217+
<a href="#" class="item-path" title="${silfn:escapeHtml(space.getPath(' > '))}">
218+
${space.getName(language)}
219+
</a>
220+
</view:arrayCellText>
221+
</c:otherwise>
222+
</c:choose>
223+
<view:arrayCellText compareOn="${space.removalDate}"
224+
text="${silfn:formatDateAndHour(space.removalDate, language)}&nbsp;(${space.removerName})"/>
225+
<view:arrayCellText>
226+
<view:icon iconName="${binRestoreIcom}" altText="${binRestoreOp}"
227+
action="javascript:onclick=restoreItem('${space.id}')"/>
228+
<view:icon iconName="${binDeleteIcon}" altText="${binDeleteOp}"
229+
action="javascript:onclick=removeItem('${space.id}')"/>
230+
<input style="vertical-align: middle" type="checkbox" name="SpaceIds" value="${space.id}"/>
231+
</view:arrayCellText>
232+
</view:arrayLine>
233+
</view:arrayLines>
234+
</view:arrayPane>
235+
</div>
236+
</c:if>
237+
<c:if test="${fn:length(removedComponents) > 0}">
238+
<div id="removedSpaces" style="margin-top: 1em;">
239+
<fmt:message key="GML.components" var="componentLabel"/>
240+
<c:set var="checkOp">
241+
<span style="float:left">${operationsLabel}</span>
242+
<input type="checkbox" id="checkAllComponents"
243+
onkeydown="jqCheckAll2(this.id, 'ComponentIds')"
244+
onclick="jqCheckAll2(this.id, 'ComponentIds')"
245+
style="float:left;margin-left:5px;padding:0;vertical-align:middle;background-color:unset;"/>
246+
</c:set>
247+
<view:arrayPane var="binContentComponents" routingAddress="ViewBin">
248+
<view:arrayColumn title="${componentLabel}" sortable="true"/>
249+
<view:arrayColumn title="${deletionDateLabel}" sortable="true"/>
250+
<view:arrayColumn title="${checkOp}" sortable="false"/>
251+
<view:arrayLines var="component" items="${removedComponents}">
252+
<jsp:useBean id="component" type="org.silverpeas.core.admin.component.model.ComponentInstLight"/>
253+
<view:arrayLine>
254+
<view:arrayCellText compareOn="${component.getLabel(language)}">
255+
<a href="#" class="item-path" title="${silfn:escapeHtml(component.getPath(' > '))}">
256+
${component.getLabel(language)}
257+
</a>
258+
</view:arrayCellText>
259+
<view:arrayCellText compareOn="${component.removalDate}"
260+
text="${silfn:formatDateAndHour(component.removalDate, language)}&nbsp;(${component.removerName})"/>
261+
<view:arrayCellText>
262+
<view:icon iconName="${binRestoreIcom}" altText="${binRestoreOp}"
263+
action="javascript:onclick=restoreItem('${component.id}')"/>
264+
<view:icon iconName="${binDeleteIcon}" altText="${binDeleteOp}"
265+
action="javascript:onclick=removeItem('${component.id}')"/>
266+
<input style="vertical-align: middle" type="checkbox" name="ComponentIds" value="${component.id}"/>
267+
</view:arrayCellText>
268+
</view:arrayLine>
269+
</view:arrayLines>
270+
</view:arrayPane>
271+
</div>
272+
</c:if>
273+
</c:otherwise>
274+
</c:choose>
242275

243-
if (emptyBin)
244-
{
245-
out.println(board.printBefore());
246-
out.println("<center>"+resource.getString("JSPP.BinEmpty")+"</center>");
247-
out.println(board.printAfter());
248-
}
249-
%>
250276
</form>
251277
</div>
252-
<%
253-
out.println(frame.printAfter());
254-
out.println(window.printAfter());
255-
%>
278+
</view:frame>
279+
</view:window>
256280
<view:progressMessage/>
257281
</view:sp-body-part>
258282
</view:sp-page>

0 commit comments

Comments
 (0)