index.jsp <%@ page language="java" contentType="text/html ...

tenuousdrunkshipInternet and Web Development

Nov 12, 2013 (3 years and 6 months ago)

451 views

index.jsp

<%@ page language="java" contentType="text/html; charset=utf
-
8" pageEncoding="utf
-
8"%>

<jsp:forward page="/sample/egovSampleList.do"/>


EgovSampleController.java

* Copyright 2008
-
2009 the original author or authors.

*

* Licensed under the Apache

License, Version 2.0 (the "License");

* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at

*

*





http://www.apache.org/licenses/LICENSE
-
2.0

*

* Unless required by applicable law or agreed to in wr
iting, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the Lic
ense.

*/

package egovframework.rte.sample.web;



import java.util.List;



import javax.annotation.Resource;



import org.springframework.stereotype.Controller;

import org.springframework.ui.Model;

import org.springframework.ui.ModelMap;

import
org.springframework.validation.BindingResult;

import org.springframework.web.bind.annotation.ModelAttribute;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;

import org.springframew
ork.web.bind.annotation.SessionAttributes;

import org.springframework.web.bind.support.SessionStatus;

import org.springmodules.validation.commons.DefaultBeanValidator;



import egovframework.rte.fdl.property.EgovPropertyService;

import egovframework.rte.pt
l.mvc.tags.ui.pagination.PaginationInfo;

import egovframework.rte.sample.service.EgovSampleService;

import egovframework.rte.sample.service.SampleDefaultVO;

import egovframework.rte.sample.service.SampleVO;




/**


* @Class Name :

EgovSampleController.java

* @Description : EgovSample Controller Class

* @Modification Information


* @

* @

수정일






수정자














수정내용

* @
---------



---------



-------------------------------

* @ 2009.03.16










최초생성

*

* @author
개발프레임웍크

실행환


개발팀

* @since 2009. 03.16

* @version 1.0

* @see

*

*

Copyright (C) by MOPAS All right reserved.

*/



@Controller

@SessionAttributes(types=SampleVO.class)

public class EgovSampleController {




/** EgovSampleService */




@Resource(name = "sampleService")




private EgovSampleService sampleService;








/** EgovPropertyService */




@Resource(name = "propertiesService")




protected EgovPropertyService propertiesService;






/** Validator */




@Resource(name = "beanValidator")


protected DefaultBeanVal
idator beanValidator;






/**


*


목록을

조회한다
. (pageing)


* @param searchVO
-

조회할

정보가

담긴

SampleDefaultVO


* @param model


* @return "/sample/egovSampleList"


* @exception Exception


*/




@RequestMapping(value="/sample/egovSampleList.do")




public String
selectSampleList(@ModelAttribute("searchVO") SampleDefaultVO searchVO,






ModelMap model)












throws Exception {










/** EgovPropertyService.sample */





searchVO.setPageUnit(propertiesService.getInt("pageUnit"));





searchVO.setPageSize(p
ropertiesService.getInt("pageSize"));










/** pageing setting */





PaginationInfo paginationInfo = new PaginationInfo();



paginationInfo.setCurrentPageNo(searchVO.getPageIndex());



paginationInfo.setRecordCountPerPage(searchVO.getPageUnit());



pa
ginationInfo.setPageSize(searchVO.getPageSize());






searchVO.setFirstIndex(paginationInfo.getFirstRecordIndex());



searchVO.setLastIndex(paginationInfo.getLastRecordIndex());



searchVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());











List sampleList = sampleService.selectSampleList(searchVO);








model.addAttribute("resultList", sampleList);
















int totCnt = sampleService.selectSampleListTotCnt(searchVO);



paginationInfo.setTotalRecordCount(totCnt);








model.addAttribute("paginationInfo", paginationInfo);
















return "/sample/egovSampleList";




}






/**


*
글을

조회한다
.


* @param sampleVO
-

조회할

정보가

담긴

VO


* @param searchVO
-

목록

조회조건

정보가

담긴

VO


* @param status


* @return @ModelAttribute("sampleVO
")
-

조회한

정보


* @exception Exception


*/




@RequestMapping("/sample/selectSample.do")




public @ModelAttribute("sampleVO")




SampleVO selectSample(












SampleVO sampleVO,












@ModelAttribute("searchVO") SampleDefaultVO searchVO) throws Exce
ption {








return sampleService.selectSample(sampleVO);




}







/**


*


등록

화면을

조회한다
.


* @param searchVO
-

목록

조회조건

정보가

담긴

VO


* @param model


* @return "/sample/egovSampleRegister"


* @exception Exception


*/




@RequestMapping(
"/sample/addSampleView.do")




public String addSampleView(












@ModelAttribute("searchVO") SampleDefaultVO searchVO, Model model)












throws Exception {








model.addAttribute("sampleVO", new SampleVO());








return "/sample/egovSample
Register";




}








/**


*
글을

등록한다
.


* @param sampleVO
-

등록할

정보가

담긴

VO


* @param searchVO
-

목록

조회조건

정보가

담긴

VO


* @param status


* @return "forward:/sample/egovSampleList.do"


* @exception Exception


*/




@RequestMapping("/sample/addSample.do")




publi
c String addSample(






@ModelAttribute("searchVO") SampleDefaultVO searchVO,










SampleVO sampleVO,












BindingResult bindingResult, Model model, SessionStatus status)




throws Exception {










// Server
-
Side Validation





beanValidator.validate(sampleVO, bindingResult);










if (bindingResult.hasErrors()) {






model.addAttribute("sampleVO", sampleVO);




return "/sample/egovSampleRegister";





}













sampleService.insertSample(sampleVO);








status.setComplete();








return "forward:/sample/egovSampleList.do";




}








/**


*


수정화면을

조회한다
.


* @param id
-

수정할



id


* @param searchVO
-

목록

조회조건

정보가

담긴

VO


* @param model


* @return "/sample/egovSampleRegister"


* @exception Exception


*/




@RequestMapping("/sample/updateSampleView.do")




public String updateSampleView(












@RequestParam("selectedId") String id ,












@ModelAttribute("searchVO") SampleDefaultVO searchVO, Model model)












throws Exception {








SampleVO

sampleVO = new SampleVO();








sampleVO.setId(id);








//
변수명은

CoC


따라

sampleVO








model.addAttribute(selectSample(sampleVO, searchVO));








return "/sample/egovSampleRegister";




}






/**


*
글을

수정한다
.


* @param sampleVO
-

수정할

정보가

담긴

VO


*

@param searchVO
-

목록

조회조건

정보가

담긴

VO


* @param status


* @return "forward:/sample/egovSampleList.do"


* @exception Exception


*/




@RequestMapping("/sample/updateSample.do")




public String updateSample(












@ModelAttribute("searchVO") SampleDefau
ltVO searchVO,












SampleVO sampleVO,












BindingResult bindingResult, Model model, SessionStatus status)












throws Exception {







beanValidator.validate(sampleVO, bindingResult);










if (bindingResult.hasErrors()) {






mo
del.addAttribute("sampleVO", sampleVO);




return "/sample/egovSampleRegister";





}













sampleService.updateSample(sampleVO);








status.setComplete();








return "forward:/sample/egovSampleList.do";




}








/**


*
글을

삭제한다
.


* @param
sampleVO
-

삭제할

정보가

담긴

VO


* @param searchVO
-

목록

조회조건

정보가

담긴

VO


* @param status


* @return "forward:/sample/egovSampleList.do"


* @exception Exception


*/




@RequestMapping("/sample/deleteSample.do")




public String deleteSample(












SampleVO
sampleVO,












@ModelAttribute("searchVO") SampleDefaultVO searchVO, SessionStatus status)












throws Exception {








sampleService.deleteSample(sampleVO);








status.setComplete();








return "forward:/sample/egovSampleList.do";




}



}