当前位置: 首页>>代码示例>>Java>>正文


Java FacesMessage.getSummary方法代码示例

本文整理汇总了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;
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:53,代码来源:CreditCardConverter.java


注:本文中的javax.faces.application.FacesMessage.getSummary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。