| sitelink3 | http://1 |
|---|---|
| extra_vars4 | ko |
| extra_vars5 | http://yunsunghan.tistory.com/tag/DWR3.0 |
| extra_vars6 | sitelink1 |
기존에 어노테이션(annotation)을 사용하지 않은 연동 방법은 다음과 같다.
<!-- DTO 객체 -->
<dwr:configuration>
<dwr:convert type="bean" class="net.max.account.Account"/>
</dwr:configuration>
<!-- Ajax 서비스 -->
<bean id="accountService" class="net.max.account.AccountServiceImpl">
<dwr:remote javascript="XmlAccountService">
<dwr:include method="getAccount" />
</dwr:remote>
</bean>
실행 결과
이와같은 설정에서 Ajax 서비스가 많으면 많을수록 XML은 길어 진다.
이것을 Annotation으로 바꿔보자.(web.xml은 기존 설정과 같으니 따로 변경할 필요가 없다.)
기존의 서비스 클래스에 @RemoteProxy, @RemoteMethod를 다음과 같이 붙여준다.(붉은색이 변경된 부분이다.)
@RemoteProxy(name="AjaxAccountService")
public class AccountServiceImpl implements AccountService {
@RemoteMethod
public Account getAccount(String id) {
return new Account(id);
}
}
@RemoteProxy의 name속성은 외부에 표현될(*.js)파일 이름이 된다. 즉 AjaxAccountService.js 파일로 생성되는 이름이다.
설정은 아래와 같다.(붉은색이 변경된 부분이다.)
......
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xmlns:dwra="http://www.directwebremoting.org/schema/spring-dwr-annotations"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
.....
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd
http://www.directwebremoting.org/schema/spring-dwr-annotations
http://www.directwebremoting.org/schema/spring-dwr-annotations.xsd">
<dwr:configuration>
<dwr:convert type="bean" class="net.max.account.Account"></dwr:convert>
</dwr:configuration>
<dwra:annotation-config />
dwra 라는 테그는 원래 없다. 그러니 annotation-config라는 것은 직접 구현해야 한다. 이러한 기능을 하는 것은 DWR3.0에서 지원될것 같다. (하지만 현재는 안된다는거....또한 아직 M2 버젼을 다운받아 테스트 하면 오류가 났다.) 그래서 외국 포험을 뒤져보니 구현한것이 있다. 그 jar를 파일을 받아 classpath 에 넣으면 해당 테크가 잘 동작한다.
물론 둘다 혼용해서 사용이 가능하다.
![]()
별다른 잇점은 없지만 DWR 기반의 프로젝트라면 XML 설정을 많이 줄이지 않을까 한다.
댓글 0
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
|---|---|---|---|---|
| 81 | [React.JS] 강좌 목록 | 황제낙엽 | 2020.05.19 | 385 |
| 80 |
Redux: React 앱의 효율적인 데이터 교류
| 황제낙엽 | 2020.05.19 | 971 |
| 79 | Jasmine 관련 | 황제낙엽 | 2020.01.13 | 492 |
| 78 | 마우스 드래그(drag)시 iframe 위에서 컨트롤 잃는 현상과 해결 방안 | 황제낙엽 | 2017.12.12 | 28270 |
| 77 | 다섯 가지의 Ajax 우수 사례 | 황제낙엽 | 2011.04.07 | 490 |
| 76 | 15+ jQuery Popup Modal Dialog Plugins and Tutorials | 황제낙엽 | 2011.03.30 | 574 |
| 75 |
$.ajax() 공략
| 황제낙엽 | 2011.03.27 | 670 |
| 74 | DWR을 이용해서 객체를 JSON으로 변환하기 | 황제낙엽 | 2011.03.25 | 347 |
| 73 |
json을 이용한 로그인 구현
| 황제낙엽 | 2011.03.25 | 832 |
| 72 | How Prototype extends the DOM (Prototype으로 DOM을 확장하는 법) | 황제낙엽 | 2011.03.24 | 695 |
| 71 | 스크랩 | 황제낙엽 | 2009.04.16 | 439 |
| 70 | YUI 스크랩 | 황제낙엽 | 2009.03.12 | 323 |
| 69 | 스크랩 | 황제낙엽 | 2009.03.11 | 316 |
| 68 | 관심 사이트 | 황제낙엽 | 2009.03.12 | 431 |
| 67 | 웹 개발 패러다임의 전환 - Flex와 Ajax의 동거 | 황제낙엽 | 2006.12.21 | 434 |
| 66 | Ajax 강의 정리 | 황제낙엽 | 2006.04.04 | 387 |
| 65 | 자바 기술을 이용한 AJAX의 활용 | 황제낙엽 | 2006.02.08 | 347 |
| 64 |
대표적인 AJAX Framework 소개
| 황제낙엽 | 2007.02.14 | 414 |
| 63 | Ajax Framework 인기 순위: Ajaxian.com | 황제낙엽 | 2007.02.13 | 368 |
| 62 |
prototype.js 를 위한 개발자 노트 (Ajax Framework)
| 황제낙엽 | 2007.02.15 | 335 |
dwr-annotations.jar