<%@page import="org.joonzis.ex.GreenVO"%>
<%@page import="java.util.List"%>
<%@page import="org.joonzis.ex.GreenDao"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function update(f){
if( f.pw.value == '' ||
f.name.value == '' ||
f.age.value == '' ||
f.addr.value == ''){
alert("모든 내용을 입력하세요");
return;
}
f.action = 'update.jsp';
f.submit();
}
</script>
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
String id = request.getParameter("id");
// 파란색 id는 아이디 입력창에서 내가 직접 id 값을 입력한 것, String id는 이 페이지에서 사용하기 위한 변수를 선언을 한 것
// Ctrl + 메소드 클릭 : 메소드 구현한 파일(위치)로 이동
// GreenDao.getInstance() : 객체
GreenVO dto = GreenDao.getInstance().getselectone(id);
// 위에서 선언한 id를 데이터 1개 출력하기 위한 함수인 getSelectOne() 함수에다가 매개변수로 넘겨줌(값 전달해줌)
pageContext.setAttribute("dto", dto);
%>
<br>
<jsp:include page="index.jsp"/>
<br><hr><br>
<h1><%=id %> 회원의 데이터</h1>
<form method="post">
<table>
<thead>
<tr>
<th>회원 번호</th>
<th>아이디</th>
<th>비밀번호</th>
<th>이름</th>
<th>나이</th>
<th>주소</th>
<th>가입일</th>
</tr>
</thead>
<tbody>
<c:choose>
<c:when test="${empty dto }">
<tr>
<td colspan="7"><%=id %>회원 정보가 없습니다.</td>
</tr>
</c:when>
<c:otherwise>
<tr>
<td>
${dto.idx }
<input type="hidden" name="idx" value="${dto.idx }">
</td>
<td>
${dto.id }
</td>
<td><input type="password" name="pw" value="${dto.pw }"></td>
<td><input type="text" name="name" value="${dto.name }"></td>
<td><input type="number" name="age" value="${dto.age }"></td>
<td><input type="text" name="addr" value="${dto.addr }"></td>
<td>
${dto.reg_date }
</td>
</tr>
</c:otherwise>
</c:choose>
</tbody>
<tfoot>
<tr>
<th colspan="7">
<input type="button" value="수정" onclick="update(this.form)">
<input type="reset" value="다시 작성">
</th>
</tr>
</tfoot>
</table>
</form>
</body>
</html>