JavaScud | Forum | JIRA | Blog |
  Dashboard > WebWork2文档中文化计划 > ... > Tags > Velocity Tags
  WebWork2文档中文化计划 Log In View a printable version of the current page.  
  Velocity Tags
Added by scud, last edited by Tin Steeler on Apr 19, 2006  (view change)
Labels: 
(None)

Velocity标签是WebWork提供的一般Tag的扩展. 只要简单的了解这些标签的访问方式: #wwxxx (...) ... #end (这里的xxx指WebWork支持的标签), 就可以马上开始使用了.

在WebWork 2.2中, 使用Velocity作为WebWork UI标签里的模版已经被移除了. 新的和遗留的2.2 UI标签已经使用FreeMarker来实现. 但是, 下面介绍的Velocity result type和Velocity directives将会被继续支持和开发下去. 默认的, WebWork的模版引擎将会使用下面介绍的Velocity语法调用FreeMarker UI标签(通过Velocity directives). 察看 模版载入 获取更多信息.

语法

例如, 在JSP中你可能这样创建一个form:

<ww:form action="updatePerson">
    <ww:textfield label="First name" name="firstName"/>
    <ww:submit value="Update"/>
</ww:form>

在Velocity中同样的form这样创建:

#wwform ("action=updatePerson")
    #wwtextfield ("label=First name" "name=firstName")
    #wwsubmit ("value=Update")
#end

块(Block)和内联(Inline)标签

你可能注意到了, 一些标签需要#end声明, 而其它的却不需要. 这是由于Velocity中的限制, 如果有 (block) 或者 内联 (inline) 标签在前面标签必须声明#end. 是这样的, 默认情况下所有的标签都是 内联 (inline) 的, 除了很少的几个, 例如 form 标签. 我们 强烈 建议你看看FreeMarker, 它在这部分和其它部分都给你提供了更多的自由.

Site running on a free Atlassian Confluence Open Source Project License granted to WebWork China. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.3 Build:#808 May 29, 2007) - Bug/feature request - Contact Administrators