本文整理汇总了Java中javax.faces.component.html.HtmlInputText.getLabel方法的典型用法代码示例。如果您正苦于以下问题:Java HtmlInputText.getLabel方法的具体用法?Java HtmlInputText.getLabel怎么用?Java HtmlInputText.getLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.faces.component.html.HtmlInputText
的用法示例。
在下文中一共展示了HtmlInputText.getLabel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import javax.faces.component.html.HtmlInputText; //导入方法依赖的package包/类
@Override
public void validate(FacesContext context, UIComponent uiComponent, Object value) throws ValidatorException {
Pattern pattern = Pattern.compile("\\[email protected]\\w+\\.\\w+");
Matcher matcher = pattern.matcher(
(CharSequence) value);
HtmlInputText htmlInputText
= (HtmlInputText) uiComponent;
String label;
if (htmlInputText.getLabel() == null
|| htmlInputText.getLabel().trim().equals("")) {
label = htmlInputText.getId();
} else {
label = htmlInputText.getLabel();
}
if (!matcher.matches()) {
FacesMessage facesMessage
= new FacesMessage(label
+ ": not a valid email address");
throw new ValidatorException(facesMessage);
}
}
示例2: validateAlphaSpace
import javax.faces.component.html.HtmlInputText; //导入方法依赖的package包/类
/**
* Validates that the passed field only contains alphabetic characters and spaces
* @param context
* @param component
* @param value
* @throws ValidatorException
*/
public void validateAlphaSpace(FacesContext context, UIComponent component, Object value) throws ValidatorException {
String valueString = (String) value;
if (!valueString.matches("[a-zA-Z ]+")) {
HtmlInputText htmlInputText = (HtmlInputText) component;
FacesMessage facesMessage = new FacesMessage(htmlInputText.getLabel() + ": only alphabetic and space characters are allowed.");
throw new ValidatorException(facesMessage);
}
}
示例3: validateState
import javax.faces.component.html.HtmlInputText; //导入方法依赖的package包/类
public void validateState(FacesContext context, UIComponent component, Object value) throws ValidatorException {
String valueString = (String) value;
if (!states.contains(valueString)) {
HtmlInputText htmlInputText = (HtmlInputText) component;
FacesMessage facesMessage = new FacesMessage(htmlInputText.getLabel() + ": Not state abbreviation");
throw new ValidatorException(facesMessage);
}
}
示例4: validateZipCode
import javax.faces.component.html.HtmlInputText; //导入方法依赖的package包/类
public void validateZipCode(FacesContext context, UIComponent component, Object value) throws ValidatorException {
String valueString = (String) value;
if (!zipCodes.contains(valueString)) {
HtmlInputText htmlInputText = (HtmlInputText) component;
FacesMessage facesMessage = new FacesMessage(htmlInputText.getLabel() + ": Not one of the allowed zip codes");
throw new ValidatorException(facesMessage);
}
}
示例5: validate
import javax.faces.component.html.HtmlInputText; //导入方法依赖的package包/类
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
String emailAddress = (String)value;
HtmlInputText htmlInputText = (HtmlInputText)component;
if (!emailAddress.matches("[A-Za-z0-9][email protected][A-Za-z0-9]+.[A-Za-z0-9]+")){
FacesMessage facesMessage = new FacesMessage(htmlInputText.getLabel()+": email format is not valid");
throw new ValidatorException(facesMessage);
}
}