com.haulmont.cuba.core.global.Messages.formatMessage()方法的使用及代码示例

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

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

Messages.formatMessage介绍

[英]Get localized message and use it as a format string for parameters provided
[中]获取本地化消息,并将其用作所提供参数的格式字符串

代码示例

代码示例来源: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-gui

@Override
  public String formatMessage(String key, Object... params) {
    if (Strings.isNullOrEmpty(messagePack)) {
      throw new IllegalStateException("messagePack is not set");
    }

    return messages.formatMessage(messagePack, key, params);
  }
}

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

protected void doHandle(WindowManager windowManager) {
    String msg = messages.formatMessage(getClass(), "mssqlDateOutOfRangeException.message");
    windowManager.showNotification(msg, Frame.NotificationType.WARNING);
  }
}

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

@Override
public String getCaption() {
  Messages messages = AppBeans.get(Messages.class);
  return messages.formatMessage(this.getClass(), "Layout.gridCell", row+1, column+1);
}

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

@Override
  protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager windowManager) {
    String msg = messages.formatMessage(getClass(), "entityAccessException.message");
    windowManager.showNotification(msg, Frame.NotificationType.WARNING);
  }
}

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

@Override
  protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager wm) {
    if (throwable == null) {
      return;
    }

    Set<ConstraintViolation<?>> violations = ((ConstraintViolationException) throwable).getConstraintViolations();

    log.error("Service has thrown validation exception. Violations: {}", violations, throwable);

    String msg = messages.formatMessage(ServiceCallValidationExceptionHandler.class, "serviceCallValidationViolation.message");
    wm.showNotification(msg, NotificationType.ERROR);
  }
}

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

public void send() {
  String text = messageField.getValue();
  Set<UserSessionEntity> sessions = TO_ALL.equals(whomOptionsGroup.getValue()) ? allSessions : selectedSessions;
  if (!sessions.isEmpty() && !StringUtils.isBlank(text)) {
    List<UUID> sessionIds = new ArrayList<>(sessions.size());
    for (UserSessionEntity session : sessions) {
      sessionIds.add(session.getId());
    }
    uss.postMessage(sessionIds, text);
    result = messages.formatMessage(getClass(), "messageWindow.report", sessions.size());
  }
  close();
}

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

@MetaProperty
@Transient
public String getName() {
  Messages messages = AppBeans.get(Messages.NAME);
  if (isTabulatedRegion()) {
    return messages.formatMessage(getClass(), "ReportRegion.tabulatedName", getOrderNum());
  } else {
    return messages.formatMessage(getClass(), "ReportRegion.simpleName", getOrderNum());
  }
}

代码示例来源: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-global

@Override
public String formatSubstitution(@Nonnull User user, @Nullable User substitutedUser) {
  Preconditions.checkNotNullArgument(user);
  if (substitutedUser == null || user.equals(substitutedUser)) {
    return formatOfficial(user);
  } else {
    return messages.formatMessage(getClass(), "onBehalfOf",
        formatOfficial(user),
        formatOfficial(substitutedUser));
  }
}

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

@Override
  public void needMinSearchStringLength(String filterString, int minSearchStringLength) {
    String message = messages.formatMessage(
        "com.haulmont.cuba.gui", "searchSelect.minimumLengthOfFilter", minSearchStringLength);
    App.getInstance().getWindowManager().showNotification(message, defaultNotificationType);
  }
};

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

@Override
public void notFoundSuggestions(String filterString) {
  String message = messages.formatMessage("com.haulmont.cuba.gui", "searchSelect.notFound", filterString);
  App.getInstance().getWindowManager().showNotification(message, defaultNotificationType);
}

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

@Override
public void authenticate(String login, String password, Locale messagesLocale) throws LoginException {
  if (!ldapTemplate.authenticate(LdapUtils.emptyLdapName(), buildPersonFilter(login), password)) {
    throw new LoginException(
        messages.formatMessage(LdapAuthProvider.class, "LoginException.InvalidLoginOrPassword", messagesLocale, login)
    );
  }
}

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

@Override
public void authenticate(String login, String password, Locale messagesLocale) throws LoginException {
  if (!ldapTemplate.authenticate(LdapUtils.emptyLdapName(), buildPersonFilter(login), password)) {
    throw new LoginException(
        messages.formatMessage(LdapAuthProvider.class, "LoginException.InvalidLoginOrPassword", messagesLocale, login)
    );
  }
}

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

@Override
  public void needMinSearchStringLength(String filterString, int minSearchStringLength) {
    Messages messages = beanLocator.get(Messages.NAME);
    String message = messages.formatMessage(
        "com.haulmont.cuba.gui", "searchSelect.minimumLengthOfFilter", minSearchStringLength);
    App.getInstance().getWindowManager().showNotification(message, defaultNotificationType);
  }
};

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

@Subscribe
  protected void onInit(InitEvent event) {
    Window window = getWindow();

    Label<String> msgLabel = uiComponents.create(Label.TYPE_STRING);
    msgLabel.setAlignment(Component.Alignment.TOP_CENTER);
    msgLabel.addStyleName(HaloTheme.LABEL_H1);
    msgLabel.setValue(messages.formatMessage(NotFoundScreen.class, "notAssociatedRoute", requestedRoute));

    window.add(msgLabel);

    window.setCaption(messages.formatMessage(NotFoundScreen.class, "tabCaption", requestedRoute));
  }
}

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

@Override
public void ready() {
  super.ready();
  if (!StringUtils.isEmpty(getItem().getName())) {
    setCaption(AppBeans.get(Messages.class).formatMessage(getClass(), "reportEditor.format", getItem().getName()));
  }
}

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

@Override
public void notFoundSuggestions(String filterString) {
  Messages messages = beanLocator.get(Messages.NAME);
  String message = messages.formatMessage("com.haulmont.cuba.gui", "searchSelect.notFound", filterString);
  App.getInstance().getWindowManager().showNotification(message, defaultNotificationType);
}

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

protected void standardFieldInit(Field field, ProcFormParam formParam) {
  field.setRequired(formParam.isRequired());
  field.setEditable(formParam.isEditable());
  field.setRequiredMessage(messages.formatMessage(AbstractFormFieldGenerator.class, "fillField", formParam.getLocCaption()));
}

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

public Field createField(ReportInputParameter parameter) {
  Field field = fieldCreationMapping.get(parameter.getType()).createField(parameter);
  field.setRequiredMessage(messages.formatMessage(this.getClass(), "error.paramIsRequiredButEmpty", parameter.getLocName()));
  field.setId("param_" + parameter.getAlias());
  field.setWidth("100%");
  field.setFrame(frame.getWrappedFrame());
  field.setEditable(true);
  field.setRequired(parameter.getRequired());
  return field;
}

相关文章