Decorator Tags

本文介绍了一种用于网页布局的技术——页面装饰器。通过特定的标签,可以在不改变原始页面内容的前提下,实现对页面头部、主体及属性的装饰。文章详细解释了各种装饰器标签的用法,包括如何插入页面头部、主体内容以及获取和使用页面属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值