index2.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" />
<title>Insert title here</title>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"/>
<link rel="stylesheet" href="/css/wijmo.min.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="/js/wijmo.min.js" type="text/javascript"></script>
<script src="/js/wijmo.input.min.js" type="text/javascript"></script>
<script src="/js/wijmo.grid.min.js" type="text/javascript"></script>
</head>
<body>
<input id="button" type="button" value="popup"/>
<script th:inline="javascript" th:fragment="js">
/*<![CDATA[*/
$( function() {
$("<div id='targetDiv'></div>").dialog({
autoOpen:false,
height:300,
width:350,
modal:true
});
function showErrorDialog() {
$("#targetDiv").load("/errorDialog/popup");
$("#targetDiv").dialog("open");
}
$("#button").on("click", function() {
showErrorDialog();
});
} );
/*]]>*/
</script>
</body>
</html>
ErrorDialogController
package com.example.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.example.dto.ErrorDialogDto;
@Controller
public class ErrorDialogController {
@RequestMapping(value = "/errorDialog", method = RequestMethod.GET)
public String index(HttpSession session) {
String d = new SimpleDateFormat("yyyyMMdd HHmmss").format(new Date());
List<String> errors = new ArrayList<>();
errors.add("xxx " + d);
errors.add("yyy " + d);
errors.add("zzz " + d);
session.setAttribute("errors", errors);
return "index2";
}
@RequestMapping(value = "/errorDialog/popup", method = RequestMethod.GET)
public String search(HttpSession session, Model model) {
List<ErrorDialogDto> errorList = new ArrayList<>();
List<String> errorCodeList = (List<String>)session.getAttribute("errors");
for ( String code : errorCodeList)
errorList.add(new ErrorDialogDto(code));
model.addAttribute("errorList", errorList);
return "errorDialog";
}
}
errorDialog.html
<div xmlns:th="http://www.thymeleaf.org">
<div id="flexGrid"></div>
<input type="button" id="ok" value="OK"/>
<script th:inline="javascript">
/*<![CDATA[*/
$( function() {
var grid = new wijmo.grid.FlexGrid('#flexGrid');
grid.initialize({
autoGenerateColumns: false,
columns: [
{ header: '番号', binding: "code", width:500},
],
selectionMode : 'None'
});
grid.itemsSource = [[${errorList}]];
$("#ok").click(function(){
$("#targetDiv").dialog("close");
});
} );
/*]]>*/
</script>
</div>
ErrorDialogDto
package com.example.dto;
public class ErrorDialogDto {
private String code;
public ErrorDialogDto(String code) {
super();
this.code = code;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}