1. AJAX 호출
$('#btnSearch').click(function(){
$.ajax({url:"${pageContext.request.contextPath}/masterComNet.do?page=selectManHoleList4Search",
dataType:"text",
success:function(data) {
data = eval("("+data+")");
$.each(data,function(){
var v_TR = "<tr>"+
"<td><input type='radio' name='selInfo' value='"+this.transmanhole_id+"'></td>"+
"<td>"+this.transmanhole_id+"</td>"+
"<td>"+this.transmanhole_nm+"</td>"+
"<td>"+this.transmanhole_type+"</td>"+
"<td>"+this.gis_x+"</td>"+
"<td>"+this.gis_y+"</td>"+
"<td>"+this.install_date+"</td>"+
"</tr>";
$("#listBody").append(v_TR);
});
}
});
});
2. iBATIS 쿼리
<!-- 리스트 조회-->
<resultMap class="java.util.HashMap" id="fafmSRMasterComNet_MHoleList_1">
<result property="transmanhole_id" column="transmanhole_id" javaType="java.lang.String" jdbcType="VARCHAR2" /> <!-- 관리번호 -->
<result property="transmanhole_nm" column="transmanhole_nm" javaType="java.lang.String" jdbcType="VARCHAR2" /> <!-- 명 -->
<result property="transmanhole_type" column="transmanhole_type" javaType="java.lang.String" jdbcType="VARCHAR2" /> <!-- 종류 -->
<result property="gis_x" column="gis_x" javaType="java.lang.String" jdbcType="NUMBER" /> <!-- X 좌표 -->
<result property="gis_y" column="gis_y" javaType="java.lang.String" jdbcType="NUMBER" /> <!-- Y 좌표 -->
<result property="install_date" column="install_date" javaType="java.lang.String" jdbcType="VARCHAR2" /> <!--설치 일자 -->
</resultMap>
<statement id="fafm.tm.MasterComNet.MHoleList.002" parameterClass="fafm.tm.MasterComNetFormVO" resultMap="fafmSRMasterComNet_MHoleList_1">
SELECT ROWNUM PAGING, RNUM, TRANSMANHOLE_ID, TRANSMANHOLE_TYPE, TRANSMANHOLE_NM, GIS_X, GIS_Y, INSTALL_DATE
FROM(
SELECT ROWNUM PAGING, RNUM, TRANSMANHOLE_ID, TRANSMANHOLE_TYPE, TRANSMANHOLE_NM, GIS_X, GIS_Y, INSTALL_DATE
FROM(
SELECT ROWNUM RNUM, TRANSMANHOLE_ID, TRANSMANHOLE_TYPE, TRANSMANHOLE_NM, GIS_X, GIS_Y, INSTALL_DATE
FROM(
SELECT TRANSMANHOLE_ID, TRANSMANHOLE_TYPE, TRANSMANHOLE_NM, GIS_X, GIS_Y, TO_CHAR(INSTALL_DATE, 'YYYY-MM-DD') INSTALL_DATE
FROM FAFMTN_TRANSMANHOLE
<include refid="fafm.tm.where-ManHoleComNet-list"/>
ORDER BY INSTALL_DATE ASC
)ORDER BY RNUM DESC
)
)WHERE PAGING BETWEEN ((4*#selPaging#)+1) AND (4*(#selPaging#+1))
</statement>
3. 쿼리 호출 부 (JAVA SOURCE)
public List<HashMap<String, Object>> selectManHoleList4Search(MasterComNetFormVO masterComNetFormVO)
{
List<HashMap<String, Object>> listManHole=null;
try{
listManHole = sqlMap.queryForList("fafm.tm.MasterComNet.MHoleList.002", masterComNetFormVO);
}catch(SQLException e){
System.out.println(getClass());
e.printStackTrace();
}
return listManHole;
}
4. JSON 형태로 반환 (JAVA SOURCE)
public void selectManHoleList4Search(HttpServletRequest request, HttpServletResponse response) throws IOException{
request.setCharacterEncoding("utf-8");
MasterComNetFormVO masterComNetFormVO = new MasterComNetFormVO();
List<HashMap<String, Object>> listManHole = null;
JSONArray jsonArray = new JSONArray();
try{
bind(request, masterComNetFormVO);
listManHole = masterComNetServ.selectManHoleList4Search(masterComNetFormVO);
if(listManHole != null && listManHole.size()>0) {
for(int i=0; i<listManHole.size(); i++){
jsonArray.add(listManHole.get(i));
}
}
response.setContentType("text/xml;charset=utf-8");
PrintWriter printWriter = response.getWriter();
printWriter.print(jsonArray.toString());
printWriter.flush();
printWriter.close();
}catch(Exception e){
e.printStackTrace();
}
}
5. JSON 형태의 반환값 AJAX 로 받기 (1번에 success 부분)
success:function(data) {
data = eval("("+data+")");
$.each(data,function(){
var v_TR = "<tr>"+
"<td><input type='radio' name='selInfo' value='"+this.transmanhole_id+"'></td>"+
"<td>"+this.transmanhole_id+"</td>"+
"<td>"+this.transmanhole_nm+"</td>"+
"<td>"+this.transmanhole_type+"</td>"+
"<td>"+this.gis_x+"</td>"+
"<td>"+this.gis_y+"</td>"+
"<td>"+this.install_date+"</td>"+
"</tr>";
$("#listBody").append(v_TR);
});
}
});
'Dev > Orvercome 3sec memory' 카테고리의 다른 글
Web Logic 에서 Java 코드로 new File 했을 때의 파일 생성 경로 (0) | 2010.12.22 |
---|---|
Web Logic 9.2 는 Servlet 2.5 지원하지 않는다. (0) | 2010.12.22 |
JAVA로 SMTP 메일 보내기 - "제목" 항목 한글 깨짐 (0) | 2010.12.07 |
5초 간격으로 DB 조회 & POPUP 공지 (0) | 2010.08.25 |
알고있자! URL (0) | 2010.05.14 |