Tapestry
  1. Tapestry
  2. TAPESTRY-1642

When the Label component has a body, it should render that rather than using the field's label

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.0.5
    • Fix Version/s: 5.0.10
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      The Label component assumes validation and label strings are to be the same.
      This is sometimes not desired, however.
      Our use-case is points displayed as part of a todo item name:

      [ ] 3 points
      [ ] 7 points
      ...

      Using code something like this:

      <div t:type="loop" t:source="itemList" t:value="item" t:volatile="true">
      <input t:type="checkbox" t:id="itemCheck" id="itemCheck" t:value="item.done" t:label="item.name"/>
      <label t:type="label" for="itemCheck">
      <span class="points">$

      {item.points} ${message:points}</span>
      </label>
      </div>

      Having explored several solutions to this problem (auto body render, body render/discard/replace parameters, mixins, body
      blocks), I prefer one which aids previewability.

      A renderBody parameter allows the body to render, assisted by the improved Any component - see TAPESTRY-1733.

      <label t:type="label" for="itemCheck" t:renderBody="true">
      <span t:type="Any" t:body="${item.points}

      $

      {message:points}

      " class="points">10 points</span>
      </label>

      (Note: this doesn't work in 5.0.5 because of the invariant expansions bug which is fixed in SVN.)

      Cheers,
      Nick.

        Issue Links

          Activity

          Hide
          Sven Homburg added a comment -

          i think that was not a good idea for the (html)-designer purpose.
          let me know if im think wrong, but nearly every designer is working
          with WYSIWYG tools and insert the label text between the label tag.

          it s realy hard to explain the designer:
          "dont forget to remove your label value after you finish your work"

          i think its more felxible, if we can parameterize this behavior.

          Show
          Sven Homburg added a comment - i think that was not a good idea for the (html)-designer purpose. let me know if im think wrong, but nearly every designer is working with WYSIWYG tools and insert the label text between the label tag. it s realy hard to explain the designer: "dont forget to remove your label value after you finish your work" i think its more felxible, if we can parameterize this behavior.

            People

            • Assignee:
              Howard M. Lewis Ship
              Reporter:
              Nick Westgate
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development