List

월요일, 12월 14, 2015

Mybatis 환경에서 답변형 게시판 구축 - 2 게시판 client 소스

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
    request.setCharacterEncoding("utf-8");
    String path=request.getContextPath();//webcontent하위경로
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<c:set var="path" value="${pageContext.request.contextPath}" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<style type="text/css">
    table tr,td{
        border-collapse: collapse;
        border : 2px solid black;
    }
</style>
<script type="text/javascript">".classpath"
$(document).ready(function(){
    //상세의 초기 처리내용
    // -  상세화면 원복 버튼 클릭
    $("#dtlBtn").hide();
    //refno는 수정하지 못하게
    $("#refno").attr("readonly",true);
    
    $("#cancel").click(function(){
        $(location).attr("href","${path}/board.do?key=list");
    })
    //del
    $("#del").click(function(){
        if (confirm("정말 삭제하시겠습니까??"== true){    //확인
            $no=$("#number").text();
            $(location).attr("href","${path}/board.do?key=del&no="+$no);
        }else{   //취소
            return;
        }
    })
    //upt
    $("#reg").click(function(){
        $no=$("#number").text();
        $("#regForm").attr("action","${path}/board.do?key=upt");
        $("#regForm").submit();
        alert("수정 되었습니다")
    })
    
    $("#coment").click(function(){//댓글 상황
        $("#dtlBtn").show();
        if($(this).text()=="답글양식"){
            $(this).text("답글등록");
            $("#del").hide();
            $("#reg").hide();
        }
        
        /*
        답글 등록시 변경할 부분
        refno ==> no
        writer ==> 새로운작성자
        title ==> RE : 기존글
        content -->  등록 가능하게 처리
        */
        $("#refno").val($("#no").val());
        $("#tdwriter").hide();
        $("#writer").attr("type","text").val("");
        $("#title").val("RE : "+$("#title").val());
        $("#content").val("\n\n\n=============\n"+$("#content").val());
        
    })
    
    $("#dtlBtn").click(function(){//상세화면 상황
        $(this).hide();
        $("#del").show();
        $("#reg").show();
        $("#coment").text("답글양식");
    })
})
function download(fold,fname){
    //alert( fold+"  :  "+fname);
    $("input[name='fold']").val(fold);
    $("input[name='fname']").val(fname);
    $("#downForm").submit();
}
</script>
</head>
<body>
<center>
<h1>상세화면입니다</h1>
<form method="post" id="downForm" action="${path}/download.do">
    <input type="hidden" name="fold"/>
    <input type="hidden" name="fname"/>
</form>
<form:form commandName="detailBoard" method="post" enctype="multipart/form-data" id="regForm">
<form:hidden path="no"/>
<table>
    <tr>
        <td>제목</td>
        <td><form:input path="title"/></td>
        <td>작성자</td>
        <td><font id="tdwriter">${detailBoard.writer}</font>
        <form:hidden path="writer"/>
        </td>
    </tr>
    <tr>    
        <td >글번호</td>
        <td id="number">${detailBoard.no }</td>
        <td width="10pt">상위 글번호</td>
        <td width="30pt"><form:input path="refno"/></td>
    </tr>
    <tr style="width: 500pt;height: 300pt">
        <td>내용</td>
        <td colspan="7"><form:textarea path="content" style="width:400pt;height:250pt"/>    </td>
    </tr>
    <tr>
        <td>File list</td>
        <c:forEach items="${detailBoard.relist}" var="rs">
        <td>
            <a href="javascript:download('${rs.fold}','${rs.fname}');">${rs.fname}</a><br>
        </td>
        </c:forEach>
    </tr>
    <tr>
        <td>최종 수정일</td>
        <td>${detailBoard.updte}</td>
        <td><input type="file" name="files" value="파일추가하기"/></td>
    </tr>
    
</table>
</form:form>
<button id="coment">답글양식</button>
<button id="dtlBtn">상세화면</button>
<button id="reg">수정하기</button>
<button id="del">삭제하기</button>
<button id="cancel">뒤로가기</button>
</center>
</body>
</html>
cs

댓글 없음:

댓글 쓰기