第17章. Seam文本
面向协作站点需要一种更有友好的标记语言,容易输入在论坛帖子、 wiki页面、博客和评论等中的格式化文本。Seam提供了<s:formattedText/>控件,显示符合Seam 文本语言的格式化文本。Seam文本用基于ANTLR( ANother Tool for Language Recognition)解析器实现。然而,你不必了解任何与使用ANTLR有关的东西。
[有关ANTLR 问题请参考http://www.antlr.org/wiki/display/ANTLR3/FAQ+-+Getting+Started]
17.1. 基本格式
这里是一个简单例子:
It's easy to make *emphasis*, |monospace|,
~deleted text~, super^scripts^ or _underlines_.
如果我们使用 <s:formattedText/>显示这些, 我们会得到下面的HTML结果:
<p>
It's easy to make <i>emphasis</i>, <tt>monospace</tt>
<del>deleted text</del>, super<sup>scripts</sup> or <u>underlines</u>.
</p>
我们能使用一个空行显示一个新段,并且用+显示一个标题:
+This is a big heading
You /must/ have some text following a heading!
++This is a smaller heading
This is the first paragraph. We can split it across multiple
lines, but we must end it with a blank line.
This is the second paragraph.
(注意:一个简单的换行符被忽略,你需要一个另外的空行,裹包着文本成为一个新段落。) 这是HTML结果:
<h1>This is a big heading</h1>
<p>
You <i>must</i> have some text following a heading!
</p>
<h2>This is a smaller heading</h2>
<p>
This is the first paragraph. We can split it across multiple
lines, but we must end it with a blank line.
</p>
<p>
This is the second paragraph.
</p>
有序列表使用#字符创建。无序列表使用=字符创建:
An ordered list:
#first item
#second item
#and even the /third/ item
An unordered list:
=an item
=another item
HTML结果:
<p>
An ordered list:
</p>
<ol>
<li>first item</li>
<li>second item</li>
<li>and even the <i>third</i> item</li>
</ol>
<p>
An unordered list:
</p>
<ul>
<li>an item</li>
<li>another item</li>
</ul>
引用部分应该用双引号括起来:
The other guy said:
"Nyeah nyeah-nee
/nyeah/ nyeah!"
But what do you think he means by "nyeah-nee"?
<p>
The other guy said:
</p>
<q>Nyeah nyeah-nee
<i>nyeah</i> nyeah!</q>
<p>
But what do you think he means by <q>nyeah-nee</q>?
</p>
17.2. 输入带特殊字符的代码和文本
象*、|、 #等特殊符号,以及象<、> 、 &等HTML字符可以使用\转义:
You can write down equations like 2\*3\=6 and HTML tags
like \<body\> using the escape character: \\.
HTML结果:
<p>
You can write down equations like 2*3=6 and HTML tags
like <body> using the escape character: \.
</p>
并且我们能使用倒引号引用代码块:
My code doesn't work:
`for (int i=0; i<100; i--)
{
doSomething();
}`
Any ideas?
结果:
<p>
My code doesn't work:
</p>
<pre>for (int i=0; i<100; i--)
{
doSomething();
}</pre>
<p>
Any ideas?
</p>
注意:内置的单间隔格式总被转义(大多数单间隔格式文本实事上是带有特殊字符的代码或标签)。所以,你能编写,例子:
This is a |<tag attribute="value"/>| example.
没有转义单间隔条内部的任何字符。缺点是你不能用任何其它方法来格式化内置的单间隔文本(斜体、下划线等等)。
17.3. 链接
使用下面语法创建一个链接:
Go to the Seam website at [=>http://jboss.com/products/seam].
或者,如果想指定链接文本:
Go to [the Seam website=>http://jboss.com/products/seam].
对高级用户,甚至自定义Seam文本解析器理解使用这种语法编写的wikiword链接是可能的。
17.4. 输入HTML
文本甚至可能包括HTML的某些有限子集(不要担心,选择的子集在跨站点脚本攻击下是安全的)。这对创建链接是有用的:
You might want to link to <a href="http://jboss.com/products/seam">something cool</a>, or even include an image: <img src="/logo.jpg"/>
以及创建表:
<table>
<tr><td>First name:</td><td>Gavin</td></tr>
<tr><td>Last name:</td><td>King</td></tr>
</table>
然而,如果你想,你能做更多的事。
分享到:
相关推荐
Practical.JBoss.Seam.Projects.pdf
JBOSS.SEAM.WEB应用开发 中文版 (美)MichaelYuan.
Apress.Beginning.JBoss.Seam.Feb.2007.rar
Apress.Beginning.JBoss.Seam.Feb.2007.pdf 自己备份用的
Beginning.JBoss.Seam.很好的东西,只有英文版
Manning.Seam.in.Action.Sep.2008.pdf
jboss.seam.simplicity.and.power.beyond.java.ee2007
seam框架需要的所有jar包,支持seam ui组件
Seam - 语境相关的组件[满江红20071230]............................................................................................................................ 1 Java EE 框架...........................
此教程从基础讲述了使用Seam的开发过程,是一本很好的入门英文教程,英文内容也比较简单
jboss seam 的英文书籍
Part 1 - Teeing off with Seam 1 Seam unifies Java EE 2 Putting seam-gen to work Part 2 – Seam fundamentals 3 The Seam life cycle 4 Components and contexts 5 The Seam component descriptor 6 Absolute ...
seam ejb jsf 搞了个小例子 自己留作资料备份
本文描述了seam+eclipse+jboss的下载地址配置过程等
2007年Shai Avidan 和Ariel Shamir论文《Seam Carving for Content-Aware Image Resizing》所提出方法的Matlab代码实现和作者的论文。 效果非常炫,而且代码不长
Seam 2.X Web Development
seam开发资料:Seam is a fully featured application framework on top of Java EE 5. It is also one of the most popular enterprise Java framework today. Seam deeply integrates many other standard-based ...
最新的SEAM 书籍,基于seam2.0,全的,625页. Manning.Seam.in.Action.Sep.2008.pdf
#Generated by seam setup #Mon Jun 08 21:07:28 CST 2009 #数据库密码 hibernate.connection.password=testSeamGen #工作目录 workspace.home=E\:/workspace_seam #实体存放路径 model.package=...
1.了解seam项目结构。后台用的是ejb3以及配置文件介绍。 2.介绍seam管理的事务、组件等。 3.介绍了jsf与seam结合使用。 4.seam项目的标签、seam-gen创建项目等。