Repository: struts Updated Branches: refs/heads/develop 935cd33f7 -> 09012d7e5 refs/heads/feature/WW-4295-localization d20c2f10b -> 8e6f198d4
[PATCH] First attempt at enabling value-labels to be pulled from Locale Files. Adding listValueKey attribute to checkboxList, radioMap, and select tags. Issues: This implementation uses the <@s.text> tag to handle the localization with an assignment. I presume this is less than idea, but I lack the knowledge of the Struts2 tag model that would suggest where to check for this on the valueStack or elsewhere. Example: public enum yesno { YES, NO; } <@s.radio name="yes no" list="#{yesno.values()}" valueKey="name()" /> <!-- this will look for the name() in the locale file and emit the localized value for the label of the radio button. Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/7f586d39 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/7f586d39 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/7f586d39 Branch: refs/heads/develop Commit: 7f586d39b7f8411e22fd13de8025f1866477fc3c Parents: 3ceb3b9 Author: adam brin <adam.b...@asu.edu> Authored: Tue Mar 18 07:36:28 2014 -0700 Committer: adam brin <adam.b...@asu.edu> Committed: Tue Mar 18 07:36:28 2014 -0700 ---------------------------------------------------------------------- core/src/main/resources/template/simple/checkboxlist.ftl | 8 +++++++- core/src/main/resources/template/simple/radiomap.ftl | 8 +++++++- core/src/main/resources/template/simple/select.ftl | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/7f586d39/core/src/main/resources/template/simple/checkboxlist.ftl ---------------------------------------------------------------------- diff --git a/core/src/main/resources/template/simple/checkboxlist.ftl b/core/src/main/resources/template/simple/checkboxlist.ftl index ba04196..9662e42 100644 --- a/core/src/main/resources/template/simple/checkboxlist.ftl +++ b/core/src/main/resources/template/simple/checkboxlist.ftl @@ -29,7 +29,13 @@ <#else> <#assign itemKey = stack.findValue('top')/> </#if> - <#if parameters.listValue??> + <#if parameters.listValueKey??> + <#-- checks the valueStack for the 'valueKey.' The valueKey is then looked-up in the locale + file for it's localized value. This is then used as a label --> + <#assign itemValue = stack.findString(parameters.listValueKey)/> + <#-- FIXME: find a better way to get the value than a call to @s.text --> + <#assign itemValue><@s.text name="${itemValue}"/></#assign> + <#elseif parameters.listValue??> <#assign itemValue = stack.findString(parameters.listValue)?default("")/> <#else> <#assign itemValue = stack.findString('top')/> http://git-wip-us.apache.org/repos/asf/struts/blob/7f586d39/core/src/main/resources/template/simple/radiomap.ftl ---------------------------------------------------------------------- diff --git a/core/src/main/resources/template/simple/radiomap.ftl b/core/src/main/resources/template/simple/radiomap.ftl index ab6d42c..183fd57 100644 --- a/core/src/main/resources/template/simple/radiomap.ftl +++ b/core/src/main/resources/template/simple/radiomap.ftl @@ -27,7 +27,13 @@ <#assign itemKey = stack.findValue('top')/> </#if> <#assign itemKeyStr = itemKey.toString() /> - <#if parameters.listValue??> + <#if parameters.listValueKey??> + <#-- checks the valueStack for the 'valueKey.' The valueKey is then looked-up in the locale + file for it's localized value. This is then used as a label --> + <#assign itemValue = stack.findString(parameters.listValueKey)/> + <#-- FIXME: find a better way to get the value than a call to @s.text --> + <#assign itemValue><@s.text name="${itemValue}"/></#assign> + <#elseif parameters.listValue??> <#assign itemValue = stack.findString(parameters.listValue)/> <#else> <#assign itemValue = stack.findString('top')/> http://git-wip-us.apache.org/repos/asf/struts/blob/7f586d39/core/src/main/resources/template/simple/select.ftl ---------------------------------------------------------------------- diff --git a/core/src/main/resources/template/simple/select.ftl b/core/src/main/resources/template/simple/select.ftl index 74277e6..f4f27bf 100644 --- a/core/src/main/resources/template/simple/select.ftl +++ b/core/src/main/resources/template/simple/select.ftl @@ -69,7 +69,13 @@ <#assign itemKey = stack.findValue('top')/> <#assign itemKeyStr = stack.findString('top')> </#if> - <#if parameters.listValue??> + <#if parameters.listValueKey??> + <#-- checks the valueStack for the 'valueKey.' The valueKey is then looked-up in the locale file for it's + localized value. This is then used as a label --> + <#assign itemValue = stack.findString(parameters.listValueKey)/> + <#-- FIXME: find a better way to get the value than a call to @s.text --> + <#assign itemValue><@s.text name="${itemValue}"/></#assign> + <#elseif parameters.listValue??> <#if stack.findString(parameters.listValue)??> <#assign itemValue = stack.findString(parameters.listValue)/> <#else>