JSP
<script language="javascript" src="jquery.blockUI.js"></script>
1. Script
$(document).ready(function() {
$('.register').click(function() {
var $register = $(this);
var tenderNum = $register.attr('id');
$.blockUI({ message: $('#ttmu103Form')
, css: {top: '25%', cursor: '', border: '1px solid #aaa', textAlign: 'center', width: '400px'}
, overlayCSS: {backgroundColor: '#eeeeee', cursor: ''}
});
$.getJSON("/S2BAdmin/ajaxTTMU103.do?forwardName=GET_TTMU103&tenderNum=" + tenderNum, function(data){
$('#TENDER_NUM_EACH').val(tenderNum);
$('#QUALIFIED_CODE').val(data.qc);
$('#MIN_SCORE').val(data.mins);
$('#MAX_SCORE').val(data.maxs);
$('#COMPANY_SEP').val(data.cs);
$('#PRICE_SCORE_CODE').val(data.psc);
$('#BASIC_SCORE').val(data.bs);
$('#PRICE_OVER_SCORE').val(data.pos);
$('#PRICE_MIN_SCORE').val(data.pms);
$('#PRICE_OVER_RATE').val(data.por);
$('#SCORE_01_MAX').val(data.s01m);
});
});
$('#save103').click(function() {
var tenderNum = $('#TENDER_NUM_EACH').val();
var QC = $('#QUALIFIED_CODE').val();
var MINS = $('#MIN_SCORE').val();
var MAXS = $('#MAX_SCORE').val();
var CS = $('#COMPANY_SEP').val();
var PSC = $('#PRICE_SCORE_CODE').val();
var BS = $('#BASIC_SCORE').val();
var POS = $('#PRICE_OVER_SCORE').val();
var PMS = $('#PRICE_MIN_SCORE').val();
var POR = $('#PRICE_OVER_RATE').val();
var S01M = $('#SCORE_01_MAX').val();
$.ajax({
type: "POST",
url: "/S2BAdmin/ajaxTTMU103.do",
data:"forwardName=EDIT_TTMU103&tenderNum=" + tenderNum +
"&QC=" + QC +
"&MINS=" + MINS +
"&MAXS=" + MAXS +
"&CS=" + CS +
"&PSC=" + PSC +
"&BS=" + BS +
"&POS=" + POS +
"&PMS=" + PMS +
"&POR=" + POR +
"&S01M=" + S01M,
success: function(response){
$response = $.trim(response);
if($response == "S"){
alert("저장이 완료 되었습니다.");
}else{ // "E"
alert("저장 중 오류가 발생 했습니다. 반드시 확인 바랍니다.");
}
$.unblockUI();
},
error: function(e){
alert("프로그램 점검이 필요합니다. 담당자에게 문의 바랍니다.");
$.unblockUI();
}
});
});
$('#close103').click(function() {
$.unblockUI();
});
$('#closeX').click(function() {
$.unblockUI();
});
});
2. HTML
<div id="ttmu103Form" style="display:none">
<p><label>조건 설정</label></p>
<p></p>
<p><label>TENDER_NUM : </label><input type="text" name="TENDER_NUM_EACH" id="TENDER_NUM_EACH" readonly /></p>
<p><label>QUALIFIED_CODE : </label><input type="text" name="QUALIFIED_CODE" id="QUALIFIED_CODE" /></p>
<p><label>MIN_SCORE : </label><input type="text" name="MIN_SCORE" id="MIN_SCORE" /></p>
<p><label>MAX_SCORE : </label><input type="text" name="MAX_SCORE" id="MAX_SCORE" /></p>
<p><label>COMPANY_SEP : </label><input type="text" name="COMPANY_SEP" id="COMPANY_SEP" /></p>
<p><label>PRICE_SCORE_CODE : </label><input type="text" name="PRICE_SCORE_CODE" id="PRICE_SCORE_CODE" /></p>
<p><label>BASIC_SCORE : </label><input type="text" name="BASIC_SCORE" id="BASIC_SCORE" /></p>
<p><label>PRICE_OVER_SCORE : </label><input type="text" name="PRICE_OVER_SCORE" id="PRICE_OVER_SCORE" /></p>
<p><label>PRICE_MIN_SCORE : </label><input type="text" name="PRICE_MIN_SCORE" id="PRICE_MIN_SCORE" /></p>
<p><label>PRICE_OVER_RATE : </label><input type="text" name="PRICE_OVER_RATE" id="PRICE_OVER_RATE" /></p>
<p><label>SCORE_01_MAX : </label><input type="text" name="SCORE_01_MAX" id="SCORE_01_MAX" /></p>
<p><span class="button large strong"><button id="save103" style="cursor:pointer;">설정</button></span> <span class="button large strong"><button id="close103">취소</button></span></p>
</div>
Class
1. Action Class
private void getTTMU103Value(HttpServletRequest request, HttpServletResponse response, ActionForm form) throws Exception {
AjaxTTMU103VO ttmu103vo = new AjaxTTMU103VO();
AjaxBiz ajaxBiz = new AjaxBiz();
String tenderNum = StringUtil.nullToSpace(request.getParameter("tenderNum"));
ttmu103vo = ajaxBiz.getTTMU103Detail(tenderNum);
if(ttmu103vo == null) ttmu103vo = new AjaxTTMU103VO();
String jsonObject = "{" +
"\"qc\" : \"" + ttmu103vo.getQualifiedCode() + "\"" +
", \"mins\" : \"" + ttmu103vo.getMinScore() + "\"" +
", \"maxs\" : \"" + ttmu103vo.getMaxScore() + "\"" +
", \"cs\" : \"" + ttmu103vo.getCompanySeq() + "\"" +
", \"psc\" : \"" + ttmu103vo.getPriceScoreCode() + "\"" +
", \"bs\" : \"" + ttmu103vo.getBasicScore() + "\"" +
", \"pos\" : \"" + ttmu103vo.getPriceOverScore() + "\"" +
", \"pms\" : \"" + ttmu103vo.getPriceMinScore() + "\"" +
", \"por\" : \"" + ttmu103vo.getPriceOverRate() + "\"" +
", \"s01m\" : \"" + ttmu103vo.getScore01Max() + "\"" +
"}";
log.debug(jsonObject + "<<===");
response.setContentType("application/json");
PrintWriter pw = response.getWriter();
pw.print(jsonObject);
pw.flush();
}
private void editTTMU103(HttpServletRequest request, HttpServletResponse response, ActionForm form) throws Exception {
AjaxTTMU103VO ttmu103vo = new AjaxTTMU103VO();
AjaxBiz ajaxBiz = new AjaxBiz();
String result = "S";
ttmu103vo.setTenderNum(StringUtil.nullToSpace(request.getParameter("tenderNum")));
ttmu103vo.setQualifiedCode(StringUtil.nullToSpace(request.getParameter("QC")));
ttmu103vo.setMinScore(StringUtil.nullToSpace(request.getParameter("MINS")));
ttmu103vo.setMaxScore(StringUtil.nullToSpace(request.getParameter("MAXS")));
ttmu103vo.setCompanySeq(StringUtil.nullToSpace(request.getParameter("CS")));
ttmu103vo.setPriceScoreCode(StringUtil.nullToSpace(request.getParameter("PSC")));
ttmu103vo.setBasicScore(StringUtil.nullToSpace(request.getParameter("BS")));
ttmu103vo.setPriceOverScore(StringUtil.nullToSpace(request.getParameter("POS")));
ttmu103vo.setPriceMinScore(StringUtil.nullToSpace(request.getParameter("PMS")));
ttmu103vo.setPriceOverRate(StringUtil.nullToSpace(request.getParameter("POR")));
ttmu103vo.setScore01Max(StringUtil.nullToSpace(request.getParameter("S01M")));
ttmu103vo.setResult(ajaxBiz.editTTMU103(ttmu103vo));
Util.doPrintValueObject(ttmu103vo);
if(ttmu103vo.getResult() < 1){
result = "E";
}
response.setContentType( "text/plain; charset=euc-kr");
response.setHeader("Cache-Control", "no-cache");
PrintWriter pw = response.getWriter();
pw.println(result);
pw.flush();
}
2. Biz Class
public AjaxTTMU103VO getTTMU103Detail(String tenderNum) throws Exception{
return ajaxDAO.selectTTMU103Detail(tenderNum);
}
public int editTTMU103(AjaxTTMU103VO ajaxTTMU103vo) throws Exception {
return ajaxDAO.updateTTMU103(ajaxTTMU103vo);
}
3. DAO Class
public AjaxTTMU103VO selectTTMU103Detail(String tenderNum) throws DBException{
try{
return (AjaxTTMU103VO)sqlMapper.queryForObject("common.ajax.select.TTMU103", tenderNum);
}catch(SQLException e){
e.printStackTrace();
throw new DBException("SQL001-selectTTMU103Detail()", e);
}
}
public int updateTTMU103(AjaxTTMU103VO ajaxTTMU103vo) throws DBException{
try{
return sqlMapper.update("common.ajax.update.TTMU103", ajaxTTMU103vo);
}catch(SQLException e){
e.printStackTrace();
throw new DBException("SQL001-updateTTMU103()", e);
}
}
XML
1. SQL XML
<select id="common.ajax.select.TTMU103" parameterClass="String" resultMap="ttmu103Result">
<![CDATA[
SELECT TENDER_NUM
, QUALIFIED_CODE
, MIN_SCORE
, MAX_SCORE
, COMPANY_SEP
, PRICE_SCORE_CODE
, BASIC_SCORE
, PRICE_OVER_SCORE
, PRICE_MIN_SCORE
, PRICE_OVER_RATE
, SCORE_01_MAX
FROM S2B.TTMU103
WHERE TENDER_NUM = #value#
]]>
</select>
<statement id="common.ajax.update.TTMU103" parameterClass="AjaxTTMU103VO" >
<![CDATA[
MERGE
INTO S2B.TTMU103 AS NEW
USING (SELECT TENDER_NUM
FROM S2B.TTMU200
WHERE TENDER_NUM = #tenderNum#) AS OLD
on NEW.TENDER_NUM = OLD.TENDER_NUM
WHEN MATCHED THEN
UPDATE
SET QUALIFIED_CODE = #qualifiedCode#
, MIN_SCORE = #minScore#
, MAX_SCORE = #maxScore#
, COMPANY_SEP = #companySeq#
, PRICE_SCORE_CODE = #priceScoreCode#
, BASIC_SCORE = #basicScore#
, PRICE_OVER_SCORE = #priceOverScore#
, PRICE_MIN_SCORE = #priceMinScore#
, PRICE_OVER_RATE = #priceOverRate#
, SCORE_01_MAX = #score01Max#
WHEN NOT MATCHED THEN
INSERT
( TENDER_NUM
, QUALIFIED_CODE
, MIN_SCORE
, MAX_SCORE
, COMPANY_SEP
, PRICE_SCORE_CODE
, BASIC_SCORE
, PRICE_OVER_SCORE
, PRICE_MIN_SCORE
, PRICE_OVER_RATE
, SCORE_01_MAX
)
VALUES
( #tenderNum#
, #qualifiedCode#
, #minScore#
, #maxScore#
, #companySeq#
, #priceScoreCode#
, #basicScore#
, #priceOverScore#
, #priceMinScore#
, #priceOverRate#
, #score01Max#
)
]]>
</statement>
2. Struts Config
<!-- Action Mapping Definitions -->
<action path="/ajaxTTMU103" type="common.ajax.action.AjaxTTMU103Action" />
<!-- ============================================== -->
'나 어제 배웠다 > Spring3' 카테고리의 다른 글
post & get 한글처리 (0) | 2014.02.28 |
---|---|
taglib bean:define 사용법 (0) | 2013.07.31 |
Using MyBatis 3 with Spring 3 Using Mapper XML Files (0) | 2011.04.29 |
ValidationForm Sample (0) | 2011.04.08 |
SimpleForm (0) | 2011.04.08 |