protected String getErrorMessage() { if ((namespace != null) && (namespace.trim().length() > 0)) { return LocalizedTextUtil.findDefaultText( XWorkMessages.MISSING_PACKAGE_ACTION_EXCEPTION, Locale.getDefault(), new String[]{namespace, actionName}); } else { return LocalizedTextUtil.findDefaultText( XWorkMessages.MISSING_ACTION_EXCEPTION, Locale.getDefault(), new String[]{actionName}); } }
public String getText(String key, List<?> args) { Object[] params; if (args != null) { params = args.toArray(); } else { params = EMPTY_ARGS; } return LocalizedTextUtil.findDefaultText(key, ActionContext.getContext().getLocale(), params); }
public String getText(String key, String[] args) { Object[] params; if (args != null) { params = args; } else { params = EMPTY_ARGS; } return LocalizedTextUtil.findDefaultText(key, ActionContext.getContext().getLocale(), params); }
public String getText(String key) { return LocalizedTextUtil.findDefaultText(key, ActionContext.getContext().getLocale()); }
/** * Returns a localized message for the specified key, aTextName, substituting variables from the * array of params into the message. Neither the key nor the message is evaluated. * * @param aTextName the message key * @param locale the locale the message should be for * @param params an array of objects to be substituted into the message text * @return A formatted message based on the specified key, or null if no localized message can be found for it */ public static String findDefaultText(String aTextName, Locale locale, Object[] params) { String defaultText = findDefaultText(aTextName, locale); if (defaultText != null) { MessageFormat mf = buildMessageFormat(defaultText, locale); return formatWithNullDetection(mf, params); } return null; }
public static String getConversionErrorMessage(String propertyName, ValueStack stack) { String defaultMessage = LocalizedTextUtil.findDefaultText(XWorkMessages.DEFAULT_INVALID_FIELDVALUE, ActionContext.getContext().getLocale(), new Object[]{ propertyName }); List<String> indexValues = getIndexValues(propertyName); propertyName = removeAllIndexesInProperytName(propertyName); String getTextExpression = "getText('" + CONVERSION_ERROR_PROPERTY_PREFIX + propertyName + "','" + defaultMessage + "')"; String message = (String) stack.findValue(getTextExpression); if (message == null) { message = defaultMessage; } else { message = MessageFormat.format(message, indexValues.toArray()); } return message; }
/** * Gets the default message. */ private static GetDefaultMessageReturnArg getDefaultMessage(String key, Locale locale, ValueStack valueStack, Object[] args, String defaultMessage) { GetDefaultMessageReturnArg result = null; boolean found = true; if (key != null) { String message = findDefaultText(key, locale); if (message == null) { message = defaultMessage; found = false; // not found in bundles } // defaultMessage may be null if (message != null) { MessageFormat mf = buildMessageFormat(TextParseUtil.translateVariables(message, valueStack), locale); String msg = formatWithNullDetection(mf, args); result = new GetDefaultMessageReturnArg(msg, found); } } return result; }