[ 
https://issues.apache.org/jira/browse/TAPESTRY-1642?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nick Westgate updated TAPESTRY-1642:
------------------------------------

    Description: 
The Label component assumes validation and label strings are to be the same.
This is sometimes not desired, however. E.g:

[ ] itemName1 (some note)
[ ] itemName2 (a different note)
...

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>10</span> <span t:type="Any" 
t:body="${message:points}">points</span>
    </label>

I would prefer:
        <span t:type="Any" t:body="${item.points} ${message:points}" 
class="points">10 points</span>
But the body parameter is treated as a literal and cached - the expansions are 
not re-evaluated in the loop.

Cheers,
Nick.

  was:
The Label component assumes validation and label strings are to be the same.
This is sometimes not desired, however. E.g:

[ ] itemName1 (some note)
[ ] itemName2 (a different note)
...

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 that 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>

Cheers,
Nick.


> Label component needs the ability to optionally render a body.
> --------------------------------------------------------------
>
>                 Key: TAPESTRY-1642
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-1642
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.0.5
>            Reporter: Nick Westgate
>            Priority: Minor
>
> The Label component assumes validation and label strings are to be the same.
> This is sometimes not desired, however. E.g:
> [ ] itemName1 (some note)
> [ ] itemName2 (a different note)
> ...
> 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>10</span> <span t:type="Any" 
> t:body="${message:points}">points</span>
>     </label>
> I would prefer:
>         <span t:type="Any" t:body="${item.points} ${message:points}" 
> class="points">10 points</span>
> But the body parameter is treated as a literal and cached - the expansions 
> are not re-evaluated in the loop.
> Cheers,
> Nick.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to