Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public String list(@ModelAttribute SampleVO sampleVO, Model model) throws Except
public String detail(@ModelAttribute SampleVO sampleVO, @RequestParam String id, Model model) throws Exception {
sampleVO.setId(id);
SampleVO detail = this.sampleService.selectSample(sampleVO);

// 현재 페이지 지정
detail.setPageIndex(sampleVO.getPageIndex());

model.addAttribute("sampleVO", detail);
return "egovSampleRegister";
}
Expand All @@ -79,12 +83,12 @@ public String add(@Valid @ModelAttribute SampleVO sampleVO, BindingResult bindin
}

@PostMapping("/sample/update")
public String update(@Valid @ModelAttribute SampleVO sampleVO, BindingResult bindingResult) throws Exception {
public String update(@Valid @ModelAttribute SampleVO sampleVO, BindingResult bindingResult, Model model) throws Exception {
if (bindingResult.hasErrors()) {
return "egovSampleRegister";
}
this.sampleService.updateSample(sampleVO);
return "redirect:/";
return this.list(sampleVO, model);
}

@PostMapping("/sample/delete")
Expand Down
14 changes: 10 additions & 4 deletions src/main/resources/templates/thymeleaf/egovSampleList.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
}

function sampleCreate() {
$(location).attr('href', contextPath + '/sample/add');
$(location).attr('href', contextPath + '/sample/add?pageIndex=[[${sampleVO.getPageIndex()}]]');
}

function sampleDetail(id) {
Expand All @@ -77,6 +77,7 @@

<form id="detailForm" th:object="${sampleVO}">
<input type="hidden" id="id" name="id"/>
<input type="hidden" id="pageIndex" name="pageIndex" th:value="${sampleVO.getPageIndex()}"/>
</form>

<!-- Search -->
Expand All @@ -85,13 +86,13 @@
<li>
<label for="searchCondition" style="visibility:hidden;" th:text="#{search.choose}"></label>
<select id="searchCondition" name="searchCondition" class="use">
<option th:text="Name" th:value="1" th:selected="${sampleVO.searchCondition} == 1"></option>
<option th:text="ID" th:value="0" th:selected="${sampleVO.searchCondition} == 0"></option>
<option th:text="카테고리ID" th:value="0" th:selected="${sampleVO.searchCondition} == 0"></option>
<option th:text="카테고리명" th:value="1" th:selected="${sampleVO.searchCondition} == 1"></option>
</select>
</li>
<li>
<label for="searchKeyword" style="visibility:hidden;display:none;" th:text="#{search.keyword}"></label>
<input type="text" id="searchKeyword" name="searchKeyword" th:value="${sampleVO.searchKeyword}" class="txt"/>
<input type="text" id="searchKeyword" name="searchKeyword" th:value="${sampleVO.searchKeyword}" class="txt" onKeyup="if(event.keyCode === 13){sampleSearch();}"/>
</li>
<li>
<span class="btn_blue_l">
Expand All @@ -108,6 +109,11 @@

<!-- List -->
<div id="table">
<div id="pageInfo" style="display: flex; justify-content: space-between;">
<span>총건수 : [[${paginationInfo.getTotalRecordCount()}]]</span>
<span>페이지 : [[${paginationInfo.getCurrentPageNo()}]]/[[${paginationInfo.getTotalPageCount()}]]</span>
</div>

<table th:width="680px">
<caption style="visibility:hidden">카테고리ID, 카테고리명, 사용여부, Description, 등록자 표시하는 테이블</caption>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
var contextPath = $('#contextPathHolder').attr('data-contextPath') ? $('#contextPathHolder').attr('data-contextPath') : '';

function sampleList() {
$(location).attr('href', contextPath + '/');
$('#detailForm').attr('method', 'post').attr('action', contextPath + '/sample/list').submit();
}

function sampleAdd() {
Expand Down Expand Up @@ -64,6 +64,7 @@
</div>

<form id="detailForm" th:object="${sampleVO}">
<input type="hidden" id="pageIndex" name="pageIndex" th:value="${sampleVO.getPageIndex()}"/>

<!-- Detail -->
<div id="table">
Expand All @@ -84,7 +85,7 @@
<label for="name"><span th:text="#{title.sample.name}"></span></label></td>
<td class="tbtd_content">
<input type="text" id="name" name="name" th:field="*{name}"
th:value="${sampleVO.name}" maxlength="30" class="txt"/>
th:value="${sampleVO.name}" maxlength="30" style="width:300px" class="txt"/>
<span th:if="${#fields.hasErrors('name')}" th:errors="*{name}">Name Error</span></td>
</tr>
<tr>
Expand Down