简体   繁体   中英

Display a status popup when a button is clicked and redirect to the parent window - SpringBoot

I have created a Spring Boot application and it displays the following table on the browser when I hit localhost:8080/displayResults

╔═════╦══════╦════════════════════╗
║ ID  ║ Name ║       Action       ║
╠═════╬══════╬════════════════════╣
║ 001 ║ one  ║ start|stop|restart ║
║ 002 ║ two  ║ start|stop|restart ║
╚═════╩══════╩════════════════════╝

I have a controller as below

@RequestMapping(value = "displayResults", method = RequestMethod.GET)
public ModelAndView getResults(ModelMap model) {
    List<Bean> beanToDisplay = handler.getData();
    return new ModelAndView("Results", "beanToDisplay", beanToDisplay);
}

The above controller is the one that displays the aforementioned table.

Now my requirement is when I click on the start button or stop button or restart button it should call another method called handler.stop() etc. This method checks the existing status of the server and starts or stops accordingly. It takes sometime (may be like 10 seconds) for this method to return a status. Until then it should display a popup as soon as the "start or stop or restart" button is clicked and then redirect back to the same parent page. Additionally I also need to pass the ID to the controller along with the start click

How do I achieve this?

alert("alert here");

is a simple js way of making a pop up box appear

for the rest i would do something like

function myFunction() {
var button //define the button here

 if (button === "GetKeyDown") 
  {
   window.location='http://www.website.com';
   alert("alert here");               
  }
}

this is the best i can think of as i haven't done much with js in a while

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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