Cascading Style Sheets
Most web applications delegate to Cascading Style Sheets (CSS) the stylistic details of the page – fonts, colors, margins, borders and alignment. This helps the remaining HTML to remain simple and semantic, which usually makes it easier
to read and maintain.
Tapestry includes sophisticated support for CSS in the form of annotation-based linking, far-future expire headers, automatic duplicate removal, and other features provided for
assets.
Default style sheet
Tapestry includes a built-in style sheet, default.css, in all HTML documents (documents that have an outer <html> element and a nested <head> element). The default.css style sheet is always ordered
first ... any additional style sheets will come after. This allows you to override Tapestry's default styles with your own.
All the styles in the default style sheet are prefixed with "t-" (for Tapestry).
Adding your own CSS
A page or component (for example, a
layout component) that is rendering the <head> tag can add a style sheet directly in the markup.
<head>
<link href="/css/site.css" rel="stylesheet" type="text/css"/>
. . .
If you want to leverage Tapestry's localization support, you may want to make use of an expansion and the "asset:" or "context:" binding prefix:
<head>
<link href="${context:css/site.css}" rel="stylesheet" type="text/css"/>
. . .
The "context:" prefix means that the remainder of the expansion is a path to a context asset, a resource in the web application root (src/main/webapp in your workspace). By contrast, the "asset:" prefix tells Tapestry to look in the class path. See
Assets.
Using the @Import annotation
Another approach to adding a style sheet is to include an @Import annotation (starting with Tapestry 5.2) on your component class:
@Import(stylesheet="context:css/site.css")
public class MyComponent
{
}
(For Tapestry 5.0 and 5.1, use the deprecated
@IncludeStyleSheet annotation instead.)
As with
included JavaScript libraries, each style sheet will only be added once, regardless of the number of components that include it via the annotation.
Conditionally loading IE-only style sheets
For Tapestry 5.2 and later, if you need to load a different style sheet for Internet Explorer browsers, or for certain versions of IE browsers, you can use Tapestry's built-in support for IE conditional comments. Just add something like the following to
your page or component (or layout) class:
@Environmental
private JavaScriptSupport javaScriptSupport;
@Inject @Path("context:layout/ie-only.css")
private Asset ieOnlyStylesheet;
void afterRender() {
javaScriptSupport.importStylesheet(new StylesheetLink(ieOnlyStylesheet, new
StylesheetOptions(null, "IE")) );
}
The above will render something like:
<!--[if IE]>
<link type="text/css" rel="stylesheet" href="/assets/1.0-SNAPSHOT/ctx/layout/ie-only.css"></link>
<![endif]-->
Naturally, the conditional part can be any other IE
conditional expression, such as "lt IE 8".
Suppressing the default style sheet
Though it should be rarely needed, you can prevent Tapestry's default style sheet from loading by overriding the configuration in your application's module (normally AppModule.java):
@Contribute(MarkupRenderer.class)
public static void deactiveDefaultCSS(OrderedConfiguration<MarkupRendererFilter> configuration)
{
configuration.override("InjectDefaultStyleheet", null);
}
Note: In Tapestry 5.3 and later, the misspelled "InjectDefaultStyleheet" is corrected to "InjectDefaultStylesheet".
分享到:
相关推荐
Tapestry是一个开源的基于servlet的应用程序框架,它使用组件对象模型来创建动态的,交互的web应用。
tapestry ,apache's mvc framework
Apache Tapestry是一个开源且基于组件的Web应用框架,主要用于创建高度可扩展的JavaApache Tapestry是一个开源且基于组件的Web应用框架,主要用于创建高度可扩展的Java Web应用程序。这个框架是由Howard Lewis Ship...
Tapestry是一个基于控件的框架以致于用它开发Web应用类似开发传统的GUI应用。你用Tapestry开发Web应用时你无需关注以操作为中心的(Operation-centric) Servlet API.引用Tapestry网站上的一句话:"Tapestry用对象...
apache-tapestry-5.3.7
apache-tapestry-5.3.8-bin.zip
Tapestry4开发指南,环境搭建和基本应用
Tapestry是一个面向组件的Java Web应用程序框架,专注于性能和开发人员的生产力。 组件只是页面的可重用部分。 创建自己的组件非常容易,Tapestry附带了许多可以使用的组件(窗体,循环,选择,复选框,网格,...
提供用于Apache Tapestry 5的WYMeditor mixin的软件包。 要使用它,只需将其依赖项添加到选择的构建工具[1]中,然后将t:mixins =“ wymeditor / Wymeditor”添加到TextArea组件。 此外,您可以使用t:options传递...
将React( )与Tapestry( )一起使用。 该库提供了将Tapestry与JSX模板结合使用的基本集成。 用法 build.gradle : repositories { jcenter() } dependencies { runtime ' de.eddyson:tapestry-react:0.33.0 '...
这个项目只是看如何使Tapestry与Spring Boot一起使用 笔记 它使用广口瓶包装 它仍然使用src / main / webapp 它不使用web.xml 去做 弄清楚如何将src / main / webapp移到资源上,或者更像是启动所期望的东西 集成...
Apache Tapestry是一个使用Java语言创建web应用的面向组件的开发框架。Tapestry应用建立在根据组件构建的页面的基础上。这个框架能够提供输入验证(input validation)、本地化/国际化(localization/...
Zubairov合作撰写了一篇文章,详细介绍Apache Tapestry 版本5——一个面向组件web框架。文章向读者展示了创建组件方法,并谈到了Tapestry中的IoC以及Ajax的相关特性 译者 沙晓兰 发布于 2008年7月2日 下午9时30...
Tapestry5最新中文教程.doc 作者 Renat Zubairov & Igor Drobiazko译者 沙晓兰 发布于 2008年7月2日 下午9时30分 社区 Java 主题 Web框架 ----------------------------------------- Tapestry5.1实例教程.pdf ...
一个web框架的IOC实现,Apache tapestry-ioc
资源名称:深入浅出Tapestry内容简介:本书以循序渐进的方式,从Tapestry框架技术的基本概念入手,讲解Tapestry框架在J2EE Web应用程序中的整体架构实现。使读者在学习如何使用Tapestry框架技术的同时,还能够获得在...
Tapestry 4 官方文档中文版本,现在中文资料比较少,和大家共享一下
tapestry 实例tapestry 实例tapestry 实例tapestry 实例
Tapestry5.0.16文档和大家一起学习