Uploaded image for project: 'XWork'
  1. XWork
  2. XW-918

Localized conversion error xwork.default.invalid.fieldvalue with more parameters

    Details

      Description

      You can override default type conversion error message defining the key xwork.default.invalid.fieldvalue into your Resource Bundle property-file, for example: xwork.default.invalid.fieldvalue=Invalid field value for field "

      {0}".
      or defining the key invalid.fieldvalue.<propertyName> for the specific field, for example: invalid.fieldvalue.property.name = Invalid field value for field "Property Name".

      This is managed by com.opensymphony.xwork2.conversion.impl.XWorkConverter.java:

      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 = removeAllIndexesInProperyName(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;
      }

      The parameter {0}

      (propertyName) is the only one parameter passed to LocalizedTextUtil.findDefaultText(...).
      It would be very useful to have a second parameter

      {1}

      with the localized label of the field (if present).

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              francescods Francesco Di Salvatore
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - 0.5h
                0.5h
                Remaining:
                Remaining Estimate - 0.5h
                0.5h
                Logged:
                Time Spent - Not Specified
                Not Specified