📜  Primefaces Inputmask

📅  最后修改于: 2021-01-08 04:09:53             🧑  作者: Mango

PrimeFaces InputMask

这是一种特殊的输入框,它强制用户输入格式化的输入。我们可以使用组件创建它。它以某种特定的方式接受输入。当我们想要格式化用户输入时,这很有用。它具有下面列出的各种属性。

InputMask属性

Attribute Default Value Return type Description
id null String It is an unique identifier of the component.
rendered true Boolean It is used to specify the rendering of the
component.
mask null Object It is used to set mask template.
slotChar null String It is a placeHolder in mask template.
value null object It is used to set value of the component.
required false Boolean It is used to make component as required.
maxlength null Integer It is used to set maximum number of characters that may be entered in
this field.
onblur null String It is used to call script when input element
loses focus.
onselect null String It is used to execute script when text within input
element is selected by user.
placeholder null String It is used to specify a short hint.
readonly false Boolean It is used to set component readonly.
size null Integer It is used to set number of characters used to determine the width of
the input element.
autoClear true Boolean It is used to clear the field on blur when incomplete input is
entered.

在下面的示例中,我们正在实现组件。本示例包含以下文件。

JSF文件

// inputMask.xhtml





input-mask














ManagedBean

// InputMask.java

package com.javatpoint;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class InputMask {
private String date;
private String phone;
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}

输出: