Uploaded image for project: '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
    • Status: Closed
    • Priority: 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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: