本文整理汇总了Java中javax.faces.application.FacesMessage.getSummary方法的典型用法代码示例。如果您正苦于以下问题:Java FacesMessage.getSummary方法的具体用法?Java FacesMessage.getSummary怎么用?Java FacesMessage.getSummary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.faces.application.FacesMessage
的用法示例。
在下文中一共展示了FacesMessage.getSummary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAsString
import javax.faces.application.FacesMessage; //导入方法依赖的package包/类
/**
* Formats the value by inserting space after every four characters for
* better readability if they don't already exist. In the process converts
* any
* <code>"-"</code> characters into blanks for consistency.
*/
@Override
public String getAsString(FacesContext context,
UIComponent component, Object value)
throws ConverterException {
String inputVal = null;
logger.log(Level.INFO, "Entering CreditCardConverter.getAsString");
if (value == null) {
return "";
}
// Value must be of a type that can be cast to a String.
try {
inputVal = (String) value;
} catch (ClassCastException ce) {
FacesMessage errMsg = new FacesMessage(CONVERSION_ERROR_MESSAGE_ID);
FacesContext.getCurrentInstance().addMessage(null, errMsg);
throw new ConverterException(errMsg.getSummary());
}
// Insert spaces after every four characters for better
// readability if they are not already present.
char[] input = inputVal.toCharArray();
StringBuilder builder = new StringBuilder(input.length + 3);
for (int i = 0; i < input.length; ++i) {
if (((i % 4) == 0) && (i != 0)) {
if ((input[i] != ' ') || (input[i] != '-')) {
builder.append(" ");
// if there any "-"'s convert them to blanks.
} else if (input[i] == '-') {
builder.append(" ");
}
}
builder.append(input[i]);
}
String convertedValue = builder.toString();
logger.log(Level.INFO, "Converted value is {0}", convertedValue);
return convertedValue;
}