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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 5.0.5
    • 5.0.10
    • tapestry-core
    • 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

              hlship Howard Lewis Ship
              sicklittlemonkey Nick Westgate
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: