3

为了使网站对移动设备友好,我想添加

<input type="email">

<input type="tel">

但我必须像使用 JSF

<h:inputText  value="#{connetcionController.userName}" />

我们如何使用 JSF 生成 html 输入类型?

我也在使用 primefaces,它们有类似的功能吗?

4

5 回答 5

6

如果你使用 PrimeFaces,你应该可以用这种方式使用typewith<p:inputText>

<p:inputText type="email" ... />

或者

<p:inputText type="tel" ... />

如果您想继续使用<h:inputText>,您需要至少升级到 JSF 2.2 并添加新的 XML 命名空间xmlns:a="http://xmlns.jcp.org/jsf/passthrough",然后您应该可以通过type这种<h:inputText>方式覆盖

<h:inputText a:type="email" ... />

或者

<h:inputText a:type="tel" ... />
于 2013-04-28T06:46:05.703 回答
4

有一个非常简单的方法。您可以使用直通。将此添加到您的 html 标记

xmlns:a="http://xmlns.jcp.org/jsf/passthrough"


然后,您可以添加您的输入类型。
你必须添加一个a:之前。

<h:inputText a:type="email" value="#{profileBean.student.privateMail}"/>


这也适用于其他一些定义,例如占位符

<h:inputSecret a:placeholder="Password" value="#{loginBean.credentials.password}" />
于 2014-12-14T12:24:24.377 回答
1

OmniFaces提供了一个解决方案。请参阅此说明,了解如何针对您的情况使用全脸。

于 2013-04-28T06:32:10.393 回答
1

您可以使用 jQuery 插件来掩盖这样的正常<input id="phone" />情况:

jQuery(function($){
   $("#phone").mask("(999) 999-9999");
});

使用这个插件:http ://digitalbush.com/projects/masked-input-plugin/

于 2013-04-28T06:39:11.213 回答
0

PrimeFaces Extensions 附带pe:inputPhone使用type="tel". 除此之外,它还提供验证、格式化和更多选项。

看:

于 2021-10-01T11:32:12.750 回答