如何让JSF渲染严格符合XHTML 1.0? [英] How to let JSF render conform XHTML 1.0 strict?
问题描述
我需要开发一个Web应用程序,该应用程序必须符合"Stanca act"(Legge Stanca).到目前为止,我已经使用jsf2.0(Mojarra)+ primefaces 3.2,但是使用
I need to develop a web application which has to be compliant with "Stanca act" (Legge Stanca). I've used jsf2.0 (Mojarra ) + primefaces 3.2 so far but I have validation problems when I use
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
尤其对于空白表单页面,以下生成的html代码:
In particular for an empty form page the following generated html code:
<form id="j_idt16" name="j_idt16" method="post" action="/econsob/faces/prova_stanca.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt16" value="j_idt16" />
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="-8952155502993391596:-7459269746161777412" autocomplete="off" />
</form>
未通过验证,原因是:
-
所需的doctype不支持form标记中的
- 属性名称 通过斯坦卡法案
- 文档类型此处不允许元素输入"(正好位于 形式) 文档类型不支持
- 属性自动完成
- attribute name in form tag is not supported by the doctype required by Stanca act
- document type does not allow element "input" here (just below the form)
- attribute autocomplete is not supported by the doctype
有没有办法解决这个问题? jsf生成的页面是否可能无法使用Strict进行验证?
Is there a way to solve this issue? Is it possible that a jsf generated page does not validate using Strict?
推荐答案
标准的JSF HTML渲染器是根据XHTML 1.0 Transitional设计的.
The standard JSF HTML renderer is designed according XHTML 1.0 Transitional.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
不过,您始终可以使用HTML5文档类型.
You can however always use the HTML5 doctype.
<!DOCTYPE html>
它比XHTML 1.0 Strict doctype更具灵活性,并且仍然强制浏览器进入标准模式.
It's more flexible than the XHTML 1.0 Strict doctype and still forces the browser in standards mode.
如果您真的打算使用XHTML 1.0 Strict,则需要设置以下上下文参数(仅Mojarra):
If you really intend to use XHTML 1.0 Strict, then you'd need to set the following context parameters (Mojarra only):
<context-param>
<param-name>com.sun.faces.autoCompleteOffOnViewState</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.enableViewStateIdRendering</param-name>
<param-value>false</param-value>
</context-param>
和/或修改适当组件的渲染器.每当某些狂热的浏览器通过某种自动完成方式修改视图状态值时,您只会冒险ViewExpiredException
.
And/or to modify the renderers of the appropriate components. You'll only risk ViewExpiredException
s whenever some overzealous browser modifies the view state value by some autocomplete means.
这篇关于如何让JSF渲染严格符合XHTML 1.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!