Example usage for org.apache.commons.validator Msg setBundle

List of usage examples for org.apache.commons.validator Msg setBundle

Introduction

In this page you can find the example usage for org.apache.commons.validator Msg setBundle.

Prototype

public void setBundle(String bundle) 

Source Link

Document

Sets the resource bundle name.

Usage

From source file:org.seasar.struts.lessconfig.factory.Backport175ValidatorAnnotationHandler.java

protected void registerMessage(Field field, BeanDesc beanDesc, PropertyDesc propDesc) {
    Method method = getMethodForValidation(propDesc);
    if (!hasAnnotation(method)) {
        super.registerMessage(field, beanDesc, propDesc);
        return;/*w w w  . ja va2 s.  com*/
    }

    Annotation annotation = Annotations.getAnnotation(Message.class, method);
    if (annotation != null) {
        Message message = (Message) annotation;
        Msg msg = new Msg();
        msg.setBundle(message.bundle());
        msg.setKey(message.key());
        msg.setName(message.name());
        msg.setResource(message.resource());
        field.addMsg(msg);
    }
}

From source file:org.seasar.struts.lessconfig.validator.config.impl.MessageConfigRegisterImpl.java

public void register(Field field, Map parameter) {
    String name = (String) parameter.get("name");
    String key = (String) parameter.get("key");
    String bundle = (String) parameter.get("bundle");
    if (StringUtil.isEmpty(bundle)) {
        bundle = this.defaultBundle;
    }//from  w  ww .j  a  va  2 s  .  co m
    String resourceStr = (String) parameter.get("resource");
    boolean resource = this.defaultResource;
    if (!StringUtil.isEmpty(resourceStr)) {
        resource = BooleanConversionUtil.toPrimitiveBoolean(resourceStr);
    }

    Msg msg = new Msg();
    msg.setBundle(bundle);
    msg.setKey(key);
    msg.setName(name);
    msg.setResource(resource);
    field.addMsg(msg);
}