티스토리 뷰

emotional developer/detect-Web

Tiles VS SiteMesh

성게군. 2014. 1. 21. 17:49


여기저기 자료를 취합.



1.

http://tiles.apache.org/framework/tutorial/pattern.html

Composite View vs. Decorator

Tiles is a composite view framework: it allows to reuse page pieces across the application. But another approach to achieve the same result is using the Decorator pattern. For example, Sitemesh is based on the Decorator pattern.

Instead of creating a template and organizing the pieces together, the Decorator pattern (in this case) takes a simple HTML page, transforms it adding the missing pieces (in our example, adding header, footer and menu) and finally renders it.

Here you can find a comparison table between the two patterns.

AspectComposite ViewDecorator
ReusabilityThe different parts of the page (template and pieces) can be reused across the whole application.Each decorator can be reused, but the decoration itself can be applied to one page at a time.
Ease of configurationEach page must be defined explicitly.The decorator can be applied even to the entire application.
Runtime configurationThe pages can be configured and organized at runtimeSince one page is decorated at a time, this feature is not present.
PerformancesLow overhead for composition.The page to be decorated has to be parsed.



2.

Tiles VS SiteMesh

  1. 장점
    • 설정이 간단. - tiles 처럼 페이지 생성마다 또 다시 설정을 정의할 필요가 없다.
    • Struts 에 종속적이지 않다.
    • struts-config.xml forward 에 실제 contents 를 담은 page 를 넘겨줄 수 있기 때문에, 실질적인 view 를 확인하기 위해 별도의 파일을 열람할 가능성이 작아진다.
    • forward 에 레이아웃이 아닌, 실제 body contents 가 들어가므로 StrutsTestCase 의 verify 를 이용해 의미있는 path 정보를 넣어 TestCase 를 작성할 수 있다.
    • include 되는 페이지에서 HEAD, 또는 BODY 태그부분의 내용을 가져오기 때문에, include 되는 페이지도 완벽한 html 페이지로 구성할 수 있다.(XHTML 사용이 가능하다.)
    • include 되는 페이지로 servlet(action) 뿐만 아니라 html, php, asp 등 다양하게 적용할 수 있다.
    • 다양한 방식의 적용이 가능하다. (url 패턴, html meta tag, parameter)
  2. 단점
    • 상속의 개념이 없다.- decorator를 여러벌 유지 하거나, parameter 혹은 <param> 태그를 사용하여 대체할 수 있다. 즉, 작성할 최종 페이지의 코드 안에서 선택하거나, decorator 에서 선택할 수 있다.
    • Servlet 2.3 이상에서만 동작한다.










'emotional developer > detect-Web' 카테고리의 다른 글

Apache Bench  (0) 2014.01.24
PageSpeed Insights  (0) 2013.10.18
Flash OBJECT and EMBED tag attributes  (0) 2011.04.13
공지사항