我想在某些iOS特定的标签属性添加到我的登录表单。 如果我有我的网页源一看,属性自动更正,autocapitalize和拼写检查不存在。 ,这是什么原因呢? 我使用JSF 2.x版本
<h:inputText id="user-name" forceId="true" value="#{login.username}" style="width:120px;"
autocorrect="off" autocapitalize="off" spellcheck="false" />
我想在某些iOS特定的标签属性添加到我的登录表单。 如果我有我的网页源一看,属性自动更正,autocapitalize和拼写检查不存在。 ,这是什么原因呢? 我使用JSF 2.x版本
<h:inputText id="user-name" forceId="true" value="#{login.username}" style="width:120px;"
autocorrect="off" autocapitalize="off" spellcheck="false" />
This is by design. You can only specify attributes which are supported by the JSF component itself (i.e. it's listed in the attribute list in the tag documentation). You can't specify arbitrary additional attributes, they will all be plain ignored.
There are several ways to solve this:
If you're already on JSF 2.2+, simply specify it as passthrough attribute:
<html ... xmlns:a="http://xmlns.jcp.org/jsf/passthrough">
...
<h:inputText ... a:autocorrect="off" />
(note that I'm using xmlns:a
instead of xmlns:p
to avoid clash with PrimeFaces default namespace)
Or:
<html ... xmlns:f="http://xmlns.jcp.org/jsf/core">
...
<h:inputText ...>
<f:passThroughAttribute name="autocorrect" value="off" />
</h:inputText>
Use OmniFaces Html5RenderKit
. Since the 1.5 release, it supports specifying custom attributes by <context-param>
. See also the showcase example or Javadoc.
Create a custom renderer. You can find several concrete examples in below answers: