简体   繁体   English

JSF 2.1 inputText类型属性

[英]JSF 2.1 inputText type attribute

We are working with JSF 2.1, and upgrading to JSF 2.2 is not an option at this time. 我们正在使用JSF 2.1,目前还不能升级到JSF 2.2。 For our application forms, I want to be able to add a type attribute to the inputText tags, so that mobile users will be presented with the correct keyboard for the data they are about to enter. 对于我们的申请表,我希望能够向inputText标签添加一个type属性,以便向移动用户提供正确的键盘,以显示他们将要输入的数据。

<h:inputText id="textID" type="text" value=""></h:inputText>
<h:inputText id="phoneNum" type="tel" value=""></h:inputText>
<h:inputText id="email" type="email" value=""></h:inputText>

How can I make this following rendered HTML happen with JSF 2.1? 如何使以下呈现的HTML在JSF 2.1中发生?

<input id="textID" type="text" value=""/>
<input id="phoneNum" type="tel" value=""/>
<input id="email" type="email" value=""/>

How can I make this following rendered HTML happen with JSF 2.1? 如何使以下呈现的HTML在JSF 2.1中发生?

  • So for the first one ( type=text ) its given by default by using h:inputText tag. 因此,对于第一个(type = text),默认情况下使用h:inputText标记给出。
  • for the athors you can use Validator to validate your expression , for example to validate email address with regular expression ,the same for type=tel 对于athor,您可以使用Validator验证您的表达方式,例如使用正则表达式验证电子邮件地址,对于type = tel

See more about validator email example here email validator example 查看更多有关此验证电子邮件例如电子邮件验证实例


Or you can use primefaces inputText tag that make you able to use : tel , email as value of the attribut type like this : 或者,您可以使用primefaces inputText标记,使其能够使用:tel,email作为属性类型的值,如下所示:

<p:inputText type="email" value="#{userBean.userName}" />

<p:inputText type="tel" value="#{userBean.telephone}" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM