'Sitemesh'에 해당되는 글 1건

  1. 2010.03.15 SiteMesh 매뉴얼 정리본

SiteMesh 매뉴얼 정리본

ITWeb/개발일반 2010.03.15 17:40
주관적으로 필요한 내용만 발췌해서 정리한 문서 입니다.
원문은 opensymphony 에서 보시면 됩니다.

원문링크 : http://www.opensymphony.com/sitemesh/


SiteMesh Flow Diagram


Character Sets

1. If possible, the web application should be configured to use UTF-8 as the default encoding. Orion allows this to be specific in orion-web.xml, as the default-charset attribute. Weblogic requires a context parameter named weblogic.httpd.inputCharset. See your application server documentation for more details. If the application server of choice does not allow to set the default charset for all web-apps, then every page (including the decorators) will need to specify the content-type. This is done by specifying a page header tag like this:

<%@ page contentType="text/html; charset=utf-8"%>

Note that some older versions of Orion do not respect the contentType page directive in included pages, so to be on the safe side, this directive should be specified in ALL pages, not just the top level one (one could use an include).

2. The next step is to inform the browser that the page contents are of a specific character set. This is done by specifying a meta tag in the HEAD element of the html page, like this:

<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">

3. The final step is informing SiteMesh's decorator mechanism that it should use a specific encoding other than the default. This is done by specifying an encoding attribute to the applyDecorator tag with the name of the encoding to use.

<page:applyDecorator name="form" encoding="utf-8">
    ...
</page:applyDecorator>


SiteMesh Tags
원문링크 : http://www.opensymphony.com/sitemesh/tags.html

아래 코드들에 대해서 <page:applyDecorator...></page:applyDecorator> 한 페이지에 포함이 된 값들은 original page's HTML 범주에 포함이 되지 않습니다.
다시 말해 <decorator:TAGS /> 를 사용하기 위해서는 1 depth 까지만 적용 된다는 점을 감안 해셔서 사용하세요.
아래 예는 단순 비교 입니다... ^^;; 감안 하시길..
좋은예의 경우 <decorator:title> 이 original page's 의 title 값으로 변경이 되지만 나쁜예의 경우는 변경이 되지 않습니다.

좋은 예)
defaultLayout.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator" %>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page" %>
<html lang="ko">
<head>
<title><decorator:title default="INDEX" /></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
<!--
document.domain=".naver.com";
//-->
</script>
<decorator:head /> <!-- 이 부분은 original page's HTML 에서 <head></head>사이의 코드를 append 합니다. -->
</head>
<decorator:body />
<page:applyDecorator name="bbsFooterLayout" />

나쁜 예)
defaultLayout.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator" %>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page" %>
<page:applyDecorator  name="bbsHeaderLayout" />
<decorator:body/>
<page:applyDecorator name="bbsFooterLayout" />

Decorator Tags

These tags are used to create page Decorators. A Decorator is typically built up from an HTML layout (or whatever is appropriate for the original page content-type) with these tags inserted to provide place-holders for the data from the original (undecorated) page.

For more details, see Building Decorators.

<decorator:head />

Description:

Insert contents of original page's HTML <head> tag. The enclosing tag will not be be written, but its contents will.

Attributes:

  • None

<decorator:body />

Description:

Insert contents of original page's HTML <body> tag. The enclosing tag will not be be written, but its contents will.

Note: the content of the body onload and onunload events (and other body attributes) can be included in the decorator by getting the property body.onload and body.onunload (the named attributes).
For example (the decorator): <body onload="<decorator:getProperty property="body.onload" />">

For more information: see getProperty.

Attributes:

  • None

<decorator:title [ default="..." ] />

Description:

Insert title of original page (obtained from <title> tag). will be used instead.

Attributes:

  • default (optional)
    Value to be inserted if title not found.

<decorator:getProperty property="..." [ default="..." ] [ writeEntireProperty="..." ]/>

Description:

Insert property of original page. See API reference for HTMLPage for details of how properties are obtained from a page.

Attributes:

  • property (required)
    Name (key) of property to insert.

  • default (optional)
    Value to be inserted if property not found.

  • writeEntireProperty (optional)
    This writes the property with a space in front including the name ( propertyName="propertyValue")
    Accepted values are true, yes and 1.
    For example:
    The decorator: <body bgcolor="White"<decorator:getProperty property="body.onload" writeEntireProperty="true" />>
    The undecorated page: <body onload="document.someform.somefield.focus();">
    The decorated page: <body bgcolor="White" onload="document.someform.somefield.focus();">

<decorator:usePage id="..." />

Description:

Expose the Page object as a variable to the decorator JSP.

Attributes:

  • id (required)
    Name of variable to assign to.

Example:

<decorator:usePage id="myPage" />
<% if ( myPage.getIntProperty("rating") == 10 ) { %>
  <b>10 out of 10!</b>
<% } %>

Page Tags

The page tags, are used to apply decorators to inline or external content from within the current page.

<page:applyDecorator name="..." [ page="..." title="..." ] >
   .....
</page:applyDecorator>

Description:

Apply a Decorator to specified content. The content can either be inline by specifying a body to the tag, or by using the result of another page by specifying the page attribute.

Attributes:

  • name (required)
    Name of the Decorator to apply to the included page.

  • page (optional)
    Points to the external resource which should expose an entire page (e.g. another JSP file producing a valid page). This attribute can be relative to the page it is being called from, or an absolute path from the context-root.

  • title (optional)
    Override the title of the page available as Page.getTitle() or <decorator:title/> from within the Decorator. This is identical to specifying <page:param name="title">...<page:param>.

Body:

The content to have the Decorator applied to.

<page:param name="..."> ... </page:param>

Description:

Pass a parameter to a Decorator. This will override the value called from Page.getProperty() or <decorator:getProperty/>. This tag is only valid inside a <page:applyDecorator> tag.

Attributes:

  • name (required)
    The name of the parameter to override.

Body:

The value of the parameter.



그 이외에 여러가지가 더 많이 있지만... 기초적인 설명으로 마무리를 하도록 하겠습니다.. :)
상세한 내용은 원문 사이트에서 참고 하세요..
신고
크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 : Comment 0

티스토리 툴바