30.30. <w:head>

Head构件对应着HTML中的head元素,用于声明页面的meta信息。一般来说,可以在w:head中包括需要引入外部资源,包括js脚本和CSS资源引用。开发者需要把这个标签放置在页面头部,这是必须的,因为Head构件负责对皮肤、外部资源(js脚本,CSS资源,images等)的统一管理。

30.30.1. 构件信息

表 30.77. 构件信息

Component Typeorg.operamasks.faces.component.html.HtmlHead
Component Familyorg.operamasks.faces.HtmlDocument
Component Classorg.operamasks.faces.component.html.HtmlHead
Tag Classorg.operamasks.faces.webapp.widget.HtmlHeadTag
Renderer Typeorg.operamasks.faces.component.html.HtmlHead
Renderer Classorg.operamasks.faces.render.widget.ajax.AjaxHtmlHeadRenderer

继承体系

+java.lang.Object

++javax.faces.component.UIComponent

+++javax.faces.component.UIComponentBase

++++org.operamasks.faces.component.html.HtmlHeadBase

+++++org.operamasks.faces.component.html.HtmlHead

30.30.2. 属性

表 30.78. 属性

binding 定义类 javax.faces.component.UIComponentBase
类型 javax.el.ValueExpression(javax.faces.component.UIComponent)
是否必须 延时求值
一个值表达式,用于把该组件链接到一个ManagedBean的某个属性。
cache 定义类 org.operamasks.faces.component.html.HtmlHeadBase
类型 javax.el.ValueExpression(java.lang.Boolean)
是否必须 延时求值
是否允许客户端缓存本页面。默认为true。此属性只影响页面本身,并不影响页面中引入的资源。若此属性设为false而页面中又使用了其他控制页面缓存的策略(例如在head中加入cache-control设置),可能会产生冲突,应避免此种用法。
extAll 定义类 org.operamasks.faces.component.html.HtmlHead
类型 javax.el.ValueExpression(java.lang.Boolean)
是否必须 延时求值
是否渲染ext-all.js,默认为false。若设置为true,则渲染的时候忽略所有其他ext的js文件(以/ext/开头),只渲染ext-base.js和ext-all.js。
id 定义类 javax.faces.component.UIComponentBase
类型 java.lang.String
是否必须 延时求值
这个组件的组件标识符。这个值在最近的命名容器类型的父组件范围内,必须是唯一的。
mergeCss 定义类 org.operamasks.faces.component.html.HtmlHead
类型 javax.el.ValueExpression(java.lang.Boolean)
是否必须 延时求值
是否合并输出的css脚本,默认为false。若设置为true,则页面对外部css文件的请求可被合并为一个,可有效减少页面请求数目。
mergeJs 定义类 org.operamasks.faces.component.html.HtmlHead
类型 javax.el.ValueExpression(java.lang.Boolean)
是否必须 延时求值
是否合并输出的javascript脚本,默认为false。若设置为true,则页面对外部javascript文件的请求可被合并为一个,可有效减少页面请求数目。
omAll 定义类 org.operamasks.faces.component.html.HtmlHead
类型 javax.el.ValueExpression(java.lang.Boolean)
是否必须 延时求值
是否渲染om-all.js,默认为false。若设置为true,则渲染的时候忽略所有其他om的js文件(以/om/开头),只渲染om-base.js和om-all.js。
rendered 定义类 javax.faces.component.UIComponentBase
类型 boolean(boolean)
是否必须 延时求值
一个标志,指出该组件是否要在任何随后的form提交过程中被渲染或处理。 这个属性的缺省值是true。

30.30.3. 构件API

30.30.4. 示例

<w:head> 
  <style type="text/css"> 
    .title { 
      background-color: silver; 
      color: #800000; 
      font: bold 10pt arial, helvetica; 
      border-bottom: solid 1px black; 
    } 
    .label { 
      background-color: silver; 
      color: black; 
      font: bold 8pt arial, helvetica; 
    } </style> 
</w:head>

以上代码会生成类似下面的head描述信息:

<head> 
  .... 
  <style type="text/css"> 
    .title { 
      background-color: silver; 
      color: #800000; 
      font: bold 10pt arial, helvetica; 
      border-bottom: solid 1px black; 
    } 
    .label { 
      background-color: silver; 
      color: black; 
      font: bold 8pt arial, helvetica; 
    } 
  </style>

  .... 
</head>