如何在操作类中识别两个不同的 JSP 页面按钮?如何基于 JSP 页面视图按钮和查看全部按钮编写条件
how to identify two different jsp page buttons in action class?how to write the condition, based on jsp page View button and view All Button?
文件名是ScanorAttach.jsp- 此文件包含查看全部按钮。 注意 - 我正在导入结果.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>
结果.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 份文件预订和照片。 如果我单击查看(预订)按钮,则会查看特定文档(仅限预订)。 如果我单击"查看全部"按钮,则应显示所有文件(预订和照片)。文件名 -文档.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>
操作类名称 - 扫描操作.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);
}
该列表无法正常工作。预订包含 2 个文件。照片包含 3 个文件.如果我在预订中删除 1 个文件,删除后仅显示一个文件。在我的项目中,它显示了所有文件(照片文件也),我想你被理解了。提前谢谢你
if(request.getParameter("viewAll.x") != null){ <br>
}else if(request.getParameter("view.x") != null){ <br>
}
在操作类中,您可以检查用户是否单击了每个按钮。
相关文章:
- onclick提交按钮JSP
- 如何根据是否通过jsp中的jstl选中单选按钮来启用和禁用下拉列表
- 如何使用按钮从 JSP 页面执行 Java 代码
- 如何在刷新jsp页面后保持单选按钮选中点击单选按钮
- 如何获取jsp上单选按钮的值
- 如何使用按钮的jsp点击事件将属性设置为struts-bean
- 页面设计<a href><按钮><输入>在JSP中
- 如何使用 JavaScript 函数在 JSP 中使用按钮移动到数据库的最后一条记录
- JSP 缓存和后退按钮
- 如何在操作类中识别两个不同的 JSP 页面按钮?如何基于 JSP 页面视图按钮和查看全部按钮编写条件
- JavaScript - JSP - 如何将函数附加到现有表单中的按钮的正确性
- 当单击 jsp 中的按钮时,它会再次调用 js 中的就绪函数.错误
- 在JSP中单击按钮时调用javascript函数
- 如何在 JSP 中的“单击”复选框时创建删除按钮
- 如何在jsp中单击按钮时将代码添加到jqPlot条形图另存为图像
- 在 JSP 中添加后退按钮
- HTML/Javascript/JSP/JSTL:如何使用 POST 数据模拟浏览器的后退按钮
- 如何在 JSP 的 Iframe 中查看 PDF 时控制下载按钮
- 从 JSP 中的现有表单提交按钮调用小程序
- 在 jsp 中使用 ajax 刷新按钮时刷新行的列