com.haulmont.cuba.core.global.Messages类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中com.haulmont.cuba.core.global.Messages类的一些代码示例,展示了Messages类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Messages类的具体详情如下:
包路径:com.haulmont.cuba.core.global.Messages
类名称:Messages

Messages介绍

[英]Central infrastructure interface to work with localized messages.
[中]用于处理本地化消息的中央基础结构接口。

代码示例

代码示例来源:origin: com.haulmont.cuba/cuba-core

@Override
  public String getMessage(String pack, String key, Locale locale) {
    return messages.getMessage(pack, key, locale);
  }
}

代码示例来源:origin: com.haulmont.reports/reports-gui

@Override
  public String getCaption() {
    return messages.getMainMessage("actions.Ok");
  }
});

代码示例来源:origin: com.haulmont.cuba/cuba-core

protected String getInvalidCredentialsMessage(String login, Locale locale) {
    return messages.formatMessage(MSG_PACK, "LoginException.InvalidLoginOrPassword", locale, login);
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-portal

@Override
public String getMessage(@Nonnull String code, Object[] args, String defaultMessage, @Nonnull Locale locale) {
  if (args != null && args.length > 0) {
    return messages.formatMainMessage(code, args, locale);
  }
  return messages.getMainMessage(code, locale);
}

代码示例来源:origin: com.haulmont.reports/reports-gui

protected String getDefaultRequiredMessage(String name) {
    Messages messages = AppBeans.get(Messages.NAME);
        return messages.formatMessage(messages.getMainMessagePack(),
        "validation.required.defaultMsg", name);
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected String loadResourceString(String caption) {
  return messages.getTools().loadString(messages.getMainMessagePack(), caption);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@Override
  public void validate(Object value) throws ValidationException {
    if (value == null || !pattern.matcher(((String) value)).matches()) {
      String msg = message != null ? messages.getTools().loadString(messagesPack, message) : "Invalid value '%s'";
      throw new ValidationException(String.format(msg, value != null ? value : ""));
    }
  }
}

代码示例来源:origin: com.haulmont.reports/reports-core

protected void appendFreeMarkerSettings(StringBuilder templateBody) {
  Messages messages = AppBeans.get(Messages.NAME);
  templateBody.append("\n<#setting boolean_format=\"").
      append(messages.getMessage(messages.getMainMessagePack(), "trueString")).
      append(",").
      append(messages.getMessage(messages.getMainMessagePack(), "falseString")).
      append("\">");
}

代码示例来源:origin: com.haulmont.charts/charts-web

protected void initLocale() {
  UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.class);
  Locale locale = userSessionSource.getLocale();
  String localeString = messages.getTools().localeToString(locale);
  if (!Objects.equals(localeString, component.getLocaleString())) {
    component.setPivotTableMessages(localeString, PivotTableLocaleHelper.getPivotTableLocaleMap(locale));
    component.setLocaleString(localeString);
    component.setEmptyDataMessage(messages.getMainMessage("pivottable.emptyDataMessage", locale));
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

public String getDefaultErrorMessage() {
  MetaClass metaClass = metadata.getClass(beanClass);
  return messages.formatMainMessage("validation.defaultMsg",
      messages.getTools().getPropertyCaption(metaClass, beanProperty));
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected String formatMainMessage(String key, Object... params) {
  return messages.formatMainMessage(key, params);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

/**
 * Main messages pack used by GenericUI components and application code.
 * <br> Set up through app property {@code cuba.messagePack} depending on the client type and set of base projects.
 *
 * <br> This method is outdated but not deprecated because it is used in lots of places. Preferred method to
 * obtain the main message pack is {@link com.haulmont.cuba.core.global.Messages#getMainMessagePack()}.
 *
 * <br> To obtain a message from the main message pack use {@link com.haulmont.cuba.core.global.Messages#getMainMessage(String)}.
 */
public static String getMessagesPack() {
  Messages messages = AppBeans.get(Messages.NAME);
  return messages.getMainMessagePack();
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@Override
  public void validate(Object value) throws ValidationException {
    if (!(value instanceof String)) {
      String msg = message != null ? messages.getTools().loadString(messagesPack, message) : "Invalid value '%s'";
      throw new ValidationException(String.format(msg, value));
    }
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-portal

@Nonnull
@Override
public String getMessage(@Nonnull String code, Object[] args, @Nonnull Locale locale) throws NoSuchMessageException {
  if (args != null && args.length > 0) {
    return messages.formatMainMessage(code, args, locale);
  }
  return messages.getMainMessage(code, locale);
}

代码示例来源:origin: com.haulmont.cuba/cuba-global

/**
 * @deprecated Use {@link #getDefaultRequiredMessage(MetaClass, String)}
 * @return default required message for specified property.
 */
@Deprecated
public String getDefaultRequiredMessage(MetaProperty metaProperty) {
  String notNullMessage = getNotNullMessage(metaProperty);
  if (notNullMessage != null) {
    return notNullMessage;
  }
  return messages.formatMessage(messages.getMainMessagePack(),
      "validation.required.defaultMsg", getPropertyCaption(metaProperty));
}

代码示例来源:origin: com.haulmont.cuba/cuba-web

protected String getDialogMessage(User user) {
  return messages.formatMainMessage(
      "toSubstitutedUser.msg",
      StringUtils.isBlank(user.getName()) ? user.getLogin() : user.getName()
  );
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected String getDefaultCaption() {
  if (messages != null) {
    // legacy behaviour
    return messages.getMessage(getClass(), id);
  } else {
    return null;
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-global

/**
   * @param temporalType a temporal type
   * @return default date format string for passed temporal type
   */
  public String getDefaultDateFormat(TemporalType temporalType) {
    return temporalType == TemporalType.DATE
        ? messages.getMainMessage("dateFormat")
        : messages.getMainMessage("dateTimeFormat");
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-portal

protected String getInvalidCredentialsMessage(String login, Locale locale) {
  return messages.formatMessage(MSG_PACK, "LoginException.InvalidLoginOrPassword", locale, login);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

public PropertyConditionDescriptor(String name,
                  @Nullable String caption,
                  String messagesPack,
                  String filterComponentName,
                  MetaClass metaClass,
                  String entityAlias) {
  super(name, filterComponentName, metaClass, entityAlias);
  this.caption = caption;
  this.messagesPack = messagesPack;
  Messages messages = AppBeans.get(Messages.NAME);
  if (!isBlank(caption)) {
    this.locCaption = messages.getTools().loadString(messagesPack, caption);
  } else {
    this.locCaption = FilterConditionUtils.getPropertyLocCaption(datasourceMetaClass, name);
  }
}

相关文章