Struts 2
  1. Struts 2
  2. WW-2171

Label tag does not use key attribute to lookup value in resources when using simple theme

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.9
    • Fix Version/s: 2.1.1
    • Component/s: Plugin - Tags
    • Labels:
      None
    • Flags:
      Patch

      Description

      When using the simple theme (setting property "struts.ui.theme" to "simple"), the struts label tag does not use the key attribute to look up label value in resources.
      It does when using the css_xhtml theme.

      Example jsp fragment:

      <s:label key="company.name"/>

      Resource file fragment:

      company.name=Company name

      Html produced by css_xhtml theme (minus some space and divs):

      <label class="label" for="xxxxx_company_name">Company name:</label>

      (I am not sure where the "for" attribute comes from. I suspect that the html label tag is produced
      by css_xhtml/controlheader-core.ftl).

      Html produced by simple theme:

      <label id="xxxxx_company_name"/>

      Html that I expected simple theme to produce:

      <label id="xxxxx_company_name">Company name</label>

      1. label-patch.txt
        3 kB
        Maja S Bratseth

        Issue Links

          Activity

          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          134d 20h 41m 1 Ted Husted 24/Jan/08 11:10
          Resolved Resolved Closed Closed
          1739d 11h 1m 1 Lukasz Lenart 28/Oct/12 22:11
          Lukasz Lenart made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Andy Chapman made changes -
          Link This issue is related to WW-3459 [ WW-3459 ]
          Andy Chapman made changes -
          Link This issue is blocked by WW-3459 [ WW-3459 ]
          Andy Chapman made changes -
          Link This issue is blocked by WW-3459 [ WW-3459 ]
          Jeff Turner made changes -
          Project Import Mon Feb 01 01:17:42 UTC 2010 [ 1264987062082 ]
          Antonio Petrelli made changes -
          Workflow Struts - editable closed status (temporary) [ 48801 ] Struts - editable closed status [ 51941 ]
          Antonio Petrelli made changes -
          Workflow Struts - editable closed status [ 44477 ] Struts - editable closed status (temporary) [ 48801 ]
          Hide
          Ted Husted added a comment -

          I think this commit missed today's build, Maja, but if you can grab the JAR tomorrow, and try it in your application, that would be great!

          Show
          Ted Husted added a comment - I think this commit missed today's build, Maja, but if you can grab the JAR tomorrow, and try it in your application, that would be great! http://people.apache.org/builds/struts/nightlies/2.x/
          Ted Husted made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Hide
          Ted Husted added a comment -

          Completed: At revision: 614842 – Thanks Maja!

          Show
          Ted Husted added a comment - Completed: At revision: 614842 – Thanks Maja!
          Ted Husted made changes -
          Assignee Ted Husted [ husted ]
          Hide
          Maxx added a comment -

          I also had this problem populating the "value" for a label, so after looking at the .ftl file, I found this:
          You have to use
          <s:label value="%

          {getText('company.name')}

          "/>

          But I agree, this is not obvious regarding the other tags...

          Note: the "label" tag is generated through the template file: <theme>/label.ftl

          Example:

          test.jsp:
          --------------
          <pre>
          s:label for "firstname" with name="test.user.firstname"
          <s:label id="l_firstname" for="firstname" name="test.user.firstname" />

          s:label for "firstname" with name="%

          {getText('test.user.firstname')}"
          <s:label id="l_firstname" for="firstname" name="%{getText('test.user.firstname')}

          " />

          s:label for "firstname" with value="%

          {getText('test.user.firstname')}"
          <s:label id="l_firstname" for="firstname" value="%{getText('test.user.firstname')}

          "></s:label>
          <pre>
          --------------

          with test.user.firstname=Firstname in a global message resource

          HTML output:
          ---------------
          <pre>
          s:label for "firstname" with name="test.user.firstname"
          <label id="l_firstname" for="firstname"></label>

          s:label for "firstname" with name="%

          {getText('test.user.firstname')}"
          <label id="l_firstname" for="firstname"></label>

          s:label for "firstname" with value="%{getText('test.user.firstname')}

          "
          <label id="l_firstname" for="firstname">Firstname</label>
          </pre>
          ---------------

          Show
          Maxx added a comment - I also had this problem populating the "value" for a label, so after looking at the .ftl file, I found this: You have to use <s:label value="% {getText('company.name')} "/> But I agree, this is not obvious regarding the other tags... Note: the "label" tag is generated through the template file: <theme>/label.ftl Example: test.jsp: -------------- <pre> s:label for "firstname" with name="test.user.firstname" <s:label id="l_firstname" for="firstname" name="test.user.firstname" /> s:label for "firstname" with name="% {getText('test.user.firstname')}" <s:label id="l_firstname" for="firstname" name="%{getText('test.user.firstname')} " /> s:label for "firstname" with value="% {getText('test.user.firstname')}" <s:label id="l_firstname" for="firstname" value="%{getText('test.user.firstname')} "></s:label> <pre> -------------- with test.user.firstname=Firstname in a global message resource HTML output: --------------- <pre> s:label for "firstname" with name="test.user.firstname" <label id="l_firstname" for="firstname"></label> s:label for "firstname" with name="% {getText('test.user.firstname')}" <label id="l_firstname" for="firstname"></label> s:label for "firstname" with value="%{getText('test.user.firstname')} " <label id="l_firstname" for="firstname">Firstname</label> </pre> ---------------
          Ted Husted made changes -
          Fix Version/s 2.1.2 [ 21861 ]
          Fix Version/s 2.1.1 [ 21863 ]
          James Holmes made changes -
          Fix Version/s 2.0.12 [ 21861 ]
          Fix Version/s 2.0.11 [ 21860 ]
          James Holmes made changes -
          Fix Version/s 2.0.11 [ 21860 ]
          Maja S Bratseth made changes -
          Flags [Patch]
          Hide
          Maja S Bratseth added a comment -

          Attached patch

          Show
          Maja S Bratseth added a comment - Attached patch
          Maja S Bratseth made changes -
          Field Original Value New Value
          Attachment label-patch.txt [ 13609 ]
          Hide
          Maja S Bratseth added a comment -

          Patch

          Show
          Maja S Bratseth added a comment - Patch
          Maja S Bratseth created issue -

            People

            • Assignee:
              Ted Husted
              Reporter:
              Maja S Bratseth
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development