30.25. <w:form>

w:form为大部分输入构件提供ajax方式提交支持。在ajax方式下,使用h:form往往不生效而应该使用w:form。通过w:form可以设置客户端校验,优化视图状态,提交事件等,多个w:form可以分组一次性同时提交。

30.25.1. 构件信息

表 30.70. 构件信息

Component Typeorg.operamasks.faces.component.widget.UIForm
Component Familyjavax.faces.Form
Component Classorg.operamasks.faces.component.widget.UIForm
Tag Classorg.operamasks.faces.webapp.widget.UIFormTag
Renderer Typeorg.operamasks.faces.component.widget.UIForm
Renderer Class(AJAX)org.operamasks.faces.render.widget.ajax.AjaxFormRenderer

继承体系

+java.lang.Object

++javax.faces.component.UIComponent

+++javax.faces.component.UIComponentBase

++++javax.faces.component.UIForm

+++++javax.faces.component.html.HtmlForm

++++++org.operamasks.faces.component.widget.base.UIFormBase

+++++++org.operamasks.faces.component.widget.UIForm

30.25.2. 属性

表 30.71. 属性

accept 定义类 javax.faces.component.html.HtmlForm
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
服务器端可以正确处理的内容类型列表,用逗号分隔
acceptcharset 定义类 javax.faces.component.html.HtmlForm
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
服务器端可以正确处理的字符集列表,用逗号分隔
binding 定义类 javax.faces.component.UIComponentBase
类型 javax.el.ValueExpression(javax.faces.component.UIComponent)
是否必须 延时求值
一个值表达式,用于把该组件链接到一个ManagedBean的某个属性。
clientValidate 定义类 org.operamasks.faces.component.widget.UIForm
类型 javax.el.ValueExpression(java.lang.Boolean)
是否必须 延时求值
表单中的组件是否进行客户端校验
dir 定义类 javax.faces.component.html.HtmlForm
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
文本的阅读方向,可选值有LTR(从左至右)和RTL(从右至左)
enctype 定义类 javax.faces.component.html.HtmlForm
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
表单提交时使用的内容类型
groupId 定义类 org.operamasks.faces.component.widget.UIForm
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
groupId,具有相同groupId的form将会一次性同时提交
id 定义类 javax.faces.component.UIComponentBase
类型 java.lang.String
是否必须 延时求值
这个组件的组件标识符。这个值在最近的命名容器类型的父组件范围内,必须是唯一的。
lang 定义类 javax.faces.component.html.HtmlForm
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
属性值和文本内容所使用的语言
msgTarget 定义类 org.operamasks.faces.component.widget.base.UIFormBase
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
form中构件错误信息文本的默认显示位置。取值为:qtip、title、side、under、none。
onclick 定义类 javax.faces.component.html.HtmlForm
类型 java.lang.String
是否必须 延时求值
onclick事件,使用设备(一般来说是鼠标)单击构件时触发
ondblclick 定义类 javax.faces.component.html.HtmlForm
类型 java.lang.String
是否必须 延时求值
ondblclick事件,使用设备(一般来说是鼠标)双击构件时触发
onkeydown 定义类 javax.faces.component.html.HtmlForm
类型 java.lang.String
是否必须 延时求值
onkeydown事件,按下设备(一般是键盘)按钮时触发
onkeypress 定义类 javax.faces.component.html.HtmlForm
类型 java.lang.String
是否必须 延时求值
onkeypress事件,按下设备(键盘)按钮并释放时触发
onkeyup 定义类 javax.faces.component.html.HtmlForm
类型 java.lang.String
是否必须 延时求值
onkeyup事件,释放设备(键盘)按钮时触发
onmousedown 定义类 javax.faces.component.html.HtmlForm
类型 java.lang.String
是否必须 延时求值
onmousedown事件,在构件上按下鼠标时触发
onmousemove 定义类 javax.faces.component.html.HtmlForm
类型 java.lang.String
是否必须 延时求值
onmousemove事件,鼠标在构件上移动时触发
onmouseout 定义类 javax.faces.component.html.HtmlForm
类型 java.lang.String
是否必须 延时求值
onmouseout事件,鼠标移出构件时触发
onmouseover 定义类 javax.faces.component.html.HtmlForm
类型 java.lang.String
是否必须 延时求值
onmouseover,鼠标移到构件上时触发
onmouseup 定义类 javax.faces.component.html.HtmlForm
类型 java.lang.String
是否必须 延时求值
onmouseup事件,释放鼠标时触发
onreset 定义类 javax.faces.component.html.HtmlForm
类型 java.lang.String
是否必须 延时求值
onreset事件,激活表单里的reset构件时触发
onsubmit 定义类 javax.faces.component.html.HtmlForm
类型 java.lang.String
是否必须 延时求值
onsubmit事件,激活表单里的submit构件时触发
ontimeout 定义类 org.operamasks.faces.component.widget.UIForm
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
form中发起的Ajax请求超时后的执行的JavaScript代码
prependId 定义类 javax.faces.component.UIForm
类型 javax.el.ValueExpression(boolean)
是否必须 延时求值
此属性为真时,Form内部的子构件的id将自动加上form构件的id作为前缀。
queueRequest 定义类 org.operamasks.faces.component.widget.UIForm
类型 javax.el.ValueExpression(java.lang.Boolean)
是否必须 延时求值
是否对form中发起的Ajax请求进行排队,默认为true
rendered 定义类 javax.faces.component.UIComponentBase
类型 boolean(boolean)
是否必须 延时求值
一个标志,指出该组件是否要在任何随后的form提交过程中被渲染或处理。 这个属性的缺省值是true。
style 定义类 javax.faces.component.html.HtmlForm
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
构件渲染时应用到构件的CSS风格,对应于元素的style属性
styleClass 定义类 javax.faces.component.html.HtmlForm
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
空格分隔的CSS风格类名列表,渲染时作为元素的"class"属性
target 定义类 javax.faces.component.html.HtmlForm
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
该属性指定用于打开document的frame名
timeout 定义类 org.operamasks.faces.component.widget.UIForm
类型 javax.el.ValueExpression(java.lang.Double)
是否必须 延时求值
form中发起的Ajax请求排队的超时时间(单位:秒),当queueRequest属性设置为true时生效.
title 定义类 javax.faces.component.html.HtmlForm
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
为构件提供的提示信息
updateLevel 定义类 org.operamasks.faces.component.widget.UIForm
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
表单的更新等级,提交时表单内部的{@link UIOutput}与{@link FormUpdatable}类组件将被自动赋予此更新等级。 取值可以是:ValueOnly, Data, Lite.
validateBeforeSubmit 定义类 org.operamasks.faces.component.widget.UIForm
类型 javax.el.ValueExpression(java.lang.Boolean)
是否必须 延时求值
表单是否需要在提交前重新校验。
validateEvents 定义类 org.operamasks.faces.component.widget.UIForm
类型 javax.el.ValueExpression(java.lang.String)
是否必须 延时求值
表单中的组件客户端校验发生的时机。

30.25.3. 构件API

30.25.4. 示例

<w:form> 
  <h:panelGrid columns="2"> 
    <f:verbatim>文本输入框:</f:verbatim> 
    <h:inputText value="#{DemoBean.skin}"/> 
    <f:verbatim>日期文本输入框:</f:verbatim> 
    <h:inputText value="#{MenuBean.date}"> 
      <f:convertDateTime pattern="yyyy/M/d"/> 
    </h:inputText> 
    <f:verbatim>数字文本输入框:</f:verbatim> 
    <h:inputText value="#{DemoBean.number}"/> 
    <f:verbatim>下拉列表框:</f:verbatim> 
    <h:selectOneMenu id="combo" value="#{ColorBean.color}"> 
      <f:selectItems value="#{ColorBean.colors}"/> 
    </h:selectOneMenu> 
  </h:panelGrid> 
  <h:panelGrid columns="2"> 
    <h:graphicImage value="images/#{ColorBean.color}.gif" rendered="#{ColorBean.color!=null}"/> 
    <h:outputText value="#{ColorBean.color}" style="color: #{ColorBean.color}"/> 
  </h:panelGrid> 
</w:form>