Stripes

Ability for stripes:options-collection to localize values

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: Release 1.4
  • Component/s: Tag Library
  • Labels:
    None

Description

Creating on behalf of Jeppe who requested this in the comments of another issue. The idea would be to localize the text that the user sees for each option.

Jeppe: do you have a good idea of how you would like this to work? Should the lookup using the 'value' attribute supplied, or the 'label' attribute supplied? Do you think this should lookup using className.value or something else?

Activity

Hide
Jeppe Cramon added a comment - 04/Apr/06 4:11 AM

I think it should lookup using the value.
I think using the className.value as lookup key is reasonable

/Jeppe

Show
Jeppe Cramon added a comment - 04/Apr/06 4:11 AM I think it should lookup using the value. I think using the className.value as lookup key is reasonable /Jeppe
Hide
Sebastian Beigel added a comment - 24/May/06 6:11 AM

Any progress on this one? Today, I discovered my need for this

I patched InputOptionsCollectionTag#doStartTag() like this:

...
Object label = null;
if (labelProperty != null) {
label = OgnlUtil.getValue(labelProperty, item);

String localizedLabel = LocalizationUtility.getLocalizedFieldName(label.toString(), ((InputTagSupport) getParent()).getParentFormTag().getAction(), locale);
if (localizedLabel != null) { label = localizedLabel; }
}
else { label = item; }

...

This works for me though it is not conform with Jeppe's/Tim's idea to use the "value" attribute to lookup the localized values. In my use case, I have to localize special labels but the "value" attribute is rendered using an id so I have to use the "label"-attribute as resource key.

Maybe we could cascade the lookup like this (execution stops with non-null result):

  • lookup by "label" (and actionPath."label") - [only if label is present!]
  • lookup by "value" (and actionPath."value")
  • use label (no lookup)
  • use value as label

What do you think?

Show
Sebastian Beigel added a comment - 24/May/06 6:11 AM Any progress on this one? Today, I discovered my need for this I patched InputOptionsCollectionTag#doStartTag() like this: ... Object label = null; if (labelProperty != null) { label = OgnlUtil.getValue(labelProperty, item); String localizedLabel = LocalizationUtility.getLocalizedFieldName(label.toString(), ((InputTagSupport) getParent()).getParentFormTag().getAction(), locale); if (localizedLabel != null) { label = localizedLabel; } } else { label = item; } ... This works for me though it is not conform with Jeppe's/Tim's idea to use the "value" attribute to lookup the localized values. In my use case, I have to localize special labels but the "value" attribute is rendered using an id so I have to use the "label"-attribute as resource key. Maybe we could cascade the lookup like this (execution stops with non-null result):
  • lookup by "label" (and actionPath."label") - [only if label is present!]
  • lookup by "value" (and actionPath."value")
  • use label (no lookup)
  • use value as label
What do you think?
Hide
Tim Fennell added a comment - 08/Jul/06 12:13 PM

I've implemented this in something similar to the manner Sebastian suggested. Though I don't think using the actionPath is appropriate here - I see drop downs as things that might be used on many pages. Therefore it will look in the following order for a non-null label:
lookup: {className}.{labelPropertyValue}
lookup: {packageName}.{className}.{labelPropertyValue}
lookup: {className}.{valuePropertyValue}
lookup: {packageName}.{className}.{valuePropertyValue}
labelPropertyValue

Where className and packageName are derived from the type of bean in the collection as opposed to the ActionBean.

Show
Tim Fennell added a comment - 08/Jul/06 12:13 PM I've implemented this in something similar to the manner Sebastian suggested. Though I don't think using the actionPath is appropriate here - I see drop downs as things that might be used on many pages. Therefore it will look in the following order for a non-null label: lookup: {className}.{labelPropertyValue} lookup: {packageName}.{className}.{labelPropertyValue} lookup: {className}.{valuePropertyValue} lookup: {packageName}.{className}.{valuePropertyValue} labelPropertyValue Where className and packageName are derived from the type of bean in the collection as opposed to the ActionBean.

People

Vote (0)
Watch (0)

Dates

  • Created:
    01/Apr/06 8:48 AM
    Updated:
    04/Jan/11 2:28 PM
    Resolved:
    08/Jul/06 12:13 PM