简体   繁体   English

如何在java中进行小型警报通知

[英]How to make small alert notification in java

I am working with Spring. 我正在使用Spring。 I have one status button which changes the status of my program, ie if I press that button my status become 1,2,3... The status gets stored in the database and program redirects to another page. 我有一个状态按钮,用于更改程序的状态,即如果按下该按钮,我的状态将变为1,2,3 ......状态将存储在数据库中,程序将重定向到另一个页面。

I want to show the changed status notification at the redirected page for a small amount of time, ie if program redirected to another page than it should show an alert anywhere on that page and the alert will then hide after some time. 我想在重定向页面上显示已更改的状态通知一小段时间,即如果程序重定向到另一个页面,则应该在该页面的任何位置显示警报,然后警报将在一段时间后隐藏。

Jsp button which changes the status: 更改状态的Jsp按钮:

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

This button will change status to 2. 此按钮将状态更改为2。

jQuery function: 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();
        }
    });

After this statusCaseIdForm will get submitted along with value of flowId 在此statusCaseIdForm之后, statusCaseIdForm将与flowId值一起提交

There are many such buttons which changes the status of program 有许多这样的按钮可以改变程序的状态

Controller class code: 控制器类代码:

@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;
}

Here i am updating my database with the status value And redirecting it to dashboard. 这里我用状态值更新我的数据库并将其重定向到仪表板。 I want to show the alert notification at the dashboard for a small period of time. 我想在仪表板上显示警报通知一小段时间。

Why don't you just add the flowId to your ModelAndView , then using JSTL in your page to display the message: 为什么不直接将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>

After that... use jQuery to remove the div after x amount of seconds. 之后...使用jQuery在x秒后删除div。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM