【发布时间】:2016-03-15 12:41:18
【问题描述】:
文件名为 ScanorAttach.jsp - 此文件包含查看全部按钮。注意-我正在导入 results.jsp。
<c:if test="${not empty scanForm.results1 || not empty scanForm.results2}">
<input type="button" value="View All" class="button float-right" onclick="showDocuments('')"/>
</c:if>
<tr>
<td>
<c:import url="/jsp/common/scan/results.jsp"/></td>
</tr>
results.jsp - 此文件包含查看按钮
<c:forEach var="result" items="${scanForm.results1}" varStatus="status">
<tr class="${zebra}">
<td>${result.documentName}</td>
<c:if test="${empty scanForm.documentId && loginuser.role.roleDesc eq 'Admin'}">
<td>${result.screenName}</td>
</c:if>
<td>
<c:choose>
<c:when test="${empty scanForm.documentId && loginuser.role.roleDesc eq 'Admin'}">
<img src="${path}/images/edit.png" title="Edit" onclick="editDocument('${result.id}');"/>
<img src="${path}/images/trash.png" title="Delete" onclick="removeDocument('${result.documentName}', '${result.id}');"/>
</c:when>
<c:otherwise>
<c:if test="${not (roleDuty.viewAccountingScanAttach
&& (scanForm.screenName eq 'INVOICE' || scanForm.screenName eq 'AR BATCH'))}">
<img src="${path}/images/icons/scanner.png" title="Scan" onclick="showComment('${result.documentName}', 'Scan');"/>
<img src="${path}/images/icons/attach.png" title="Attach" onclick="showComment('${result.documentName}', 'Attach');"/>
</c:if>
<img src="${path}/images/icons/preview.png" title="View" onclick="showDocuments('${result.documentName}')"/>
<c:if test="${result.uploadCount > 0}">
<span class="red-90" style="vertical-align: super">
(${result.uploadCount})
</span>
</c:if>
</c:otherwise>
</c:choose>
</td>
</tr>
</c:forEach>
例如,我有 2 个文件预订和照片。如果我单击查看(预订)按钮,则查看特定文档(仅限预订)。如果我单击查看所有按钮,则应显示所有文件(预订和照片)。 文件名 -documents.jsp
<div class="results-container">
<table width="100%" cellpadding="0" cellspacing="1" class="display-table" id="filelist">
<thead>
<tr>
<th><a href="javascript:doSort('documentName')">Document Name</a></th>
<th><a href="javascript:doSort('fileName')">File Name</a></th>
<th><a href="javascript:doSort('fileSize')">File Size</a></th>
<th><a href="javascript:doSort('operation')">Operation</a></th>
<th><a href="javascript:doSort('operationDate')">Operation Date</a></th>
<th><a href="javascript:doSort('status')">Status</a></th>
<th><a href="javascript:doSort('comment')">Comments</a></th>
<th>Action</th>
</tr>
</thead>
<tbody>
<c:set var="zebra" value="odd"/>
<c:forEach var="result" items="${scanForm.results}" varStatus="status">
<tr class="${zebra}">
<td>${result.documentName}</td>
<td>${result.fileName}</td>
<td>${result.fileSize}</td>
<td>${result.operation}</td>
<td>${result.operationDate}</td>
<td class="receivedMasterStatus${status.index}">${result.status}</td>
<td>${str:splitter(result.comments, 75, '<br/>')}</td>
<td>
<img src="${path}/images/icons/preview.png"
title="View" onclick="viewDocument('${result.fileName}', '${result.fileLocation}/${result.fileName}')"/>
<c:choose>
<c:when test="${roleDuty.deleteAttachedDocuments eq 'true' && not empty results3}">
<img src="${path}/images/trash.png"
title="Delete" onclick="deleteDocumentSop('${result.id}', '${result.fileName}', '${result.documentName}')"/>
</c:when>
<c:otherwise>
<c:if test="${roleDuty.deleteAttachedDocuments eq 'true'}">
<img src="${path}/images/trash.png"
title="Delete" onclick="deleteDocument('${result.id}', '${result.fileName}', '${result.documentName}')"/>
</c:if>
</c:otherwise>
</c:choose>
</td>
</tr>
动作类名-ScanAction.jsp
public ActionForward showDocuments(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ScanForm scanForm = (ScanForm) form;
if (CommonUtils.isNotEmpty(scanForm.getScreenName())) {
List<ResultModel> results = new ScanDAO().getDocuments(scanForm.getScreenName(), scanForm.getDocumentName(), scanForm.getDocumentId());
scanForm.setResults(results);
}
request.setAttribute("results3", request.getSession().getAttribute("results3"));
return mapping.findForward(DOCUMENTS);
}
public ActionForward deleteDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ScanForm scanForm = (ScanForm) form;
DocumentStoreLogDAO documentDAO = new DocumentStoreLogDAO();
DocumentStoreLog document = documentDAO.findById(scanForm.getId());
File file = new File(document.getFileLocation(), document.getFileName());
if (file.exists()) {
file.delete();
}
request.setAttribute("message", document.getFileName() + " is deleted successfully");
documentDAO.delete(document);
// scanForm.setDocumentName(""); here i want to write condition and also how to differentiate view and View All Button.
return showDocuments(mapping, form, request, response);
}
列表无法正常工作。Booking 包含 2 个文件。照片包含 3 个文件。如果我在预订中删除 1 个文件,删除后只显示一个文件。在我的项目中,它显示了所有文件(也包括照片文件)。我想你已经理解了。提前谢谢你
【问题讨论】:
标签: javascript java jquery jsp struts-1