【问题标题】:How to make small alert notification in java如何在java中制作小警报通知
【发布时间】:2016-06-21 11:26:52
【问题描述】:

我正在使用 Spring。我有一个状态按钮可以更改程序的状态,即如果我按下该按钮,我的状态将变为 1,2,3... 状态存储在数据库中,程序重定向到另一个页面。

我想在重定向页面上显示更改状态通知一小段时间,即如果程序重定向到另一个页面,它应该在该页面的任何位置显示警报,然后警报将在一段时间后隐藏。

改变状态的Jsp按钮:

<button onclick="statusClicked(${caseInfo.id},2,'Final')">Mark as Final</button>

此按钮将状态更改为 2。

jQuery 函数:

function statusClicked(caseId,flowId,status){
    jConfirm("Are you sure to make the case '" + status + "'?", "Confirm Dialog", function(r) {
        if (r) {
            $("#statusCaseId").val(caseId);
            $("#statusFlowId").val(flowId);
            $("#statusCaseIdForm").submit();
        }
    });

在此之后statusCaseIdForm 将与flowId 的值一起提交

有很多这样的按钮可以改变程序的状态

控制器类代码:

@RequestMapping(value = "/updateFlow", method = RequestMethod.POST)
public ModelAndView updateFlowGet(@RequestParam Integer caseId,@RequestParam Integer flowId) {
    ClientService clientService = ServiceLocator.getClientService();
    MasterService masterService = ServiceLocator.getMasterService();
    CreditCase creditcase =clientService.getCase(caseId);
    WorkflowStatus workStatus=masterService.getworkflowStatus(flowId);
    creditcase.setStatusId(flowId);
    creditcase.setStatusName(workStatus.getName());
    masterService.addCreditCase(creditcase);
    ModelAndView model = new ModelAndView("redirect:/Dashboard");
    return model;
}

在这里,我正在使用状态值更新我的数据库并将其重定向到仪表板。我想在仪表板上显示一小段时间的警报通知。

【问题讨论】:

  • 请分享您的代码。
  • 好的,等我分享

标签: java jquery spring jsp


【解决方案1】:

你为什么不把flowId添加到你的ModelAndView,然后在你的页面中使用JSTL来显示消息:

<div id="warning">
    <c:choose>
        <c:when test="${flowId eq 1}">This is the message for 1</c:when>
        <c:when test="${flowId eq 2}">This is the message for 2</c:when>
        <c:when test="${flowId eq 3}">This is the message for 3</c:when>
    </c:choose>
</div>

之后...在 x 秒后使用 jQuery 删除 div。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多