You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Robert J. Walker" <rw...@mshare.net> on 2007/01/24 19:40:24 UTC

Radio button labels

I'm having trouble rendering <label> tags for individual radio buttons in Tapestry 4.1. Simplified example:

<div jwcid="@RadioGroup" selected="ognl:choice">
  <div jwcid="@For" source="ognl:choices" value="ognl:curChoice">
    <div jwcid="@Radio" value="ognl:curChoice" />
    <span jwcid="@Insert" value="ognl:curChoice.label" raw="true"/>
  </div>
</div>

This works fine, except that I'd like for each radio button to have a <label> tag rendered for it so that the labels are actually clickable. There doesn't seem to be a simple way to do this since the Radio component, strangely, does NOT descend from IFormComponent, so the FieldLabel component refuses to have anything to do with it.

The only solution I can think of is to create my own custom component (possibly subclassing Radio) that emits the radio button AND the label. Anyone else have a better idea?

Robert J. Walker


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Radio button labels

Posted by "Robert J. Walker" <rw...@mshare.net>.
I ultimately just created a LabeledRadio component that did the trick. It's not very flexible; the label ALWAYS immediately follows the radio button in the source, which may not always be desirable, but it does the job that we need it to do.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Radio button labels

Posted by Jesse Kuhnert <jk...@gmail.com>.
If it makes you feel any better the Radio component has driven me
crazy ever since early tacos days...The clash of concepts between a
group with the same name + individual component identifiers that works
cross browser has yet to produce a happy result.

If anyone figures anything out let us know. ;)

On 1/24/07, Robert J. Walker <rw...@mshare.net> wrote:
> andyhot wrote:
>
> > if you use
> > <div jwcid="curRadio@Radio" value="ognl:curChoice" />
>
> > then
>
> > <label jwcid="@Any" for="clientId:curRadio"><span jwcid="@Insert"
> > value="ognl:curChoice.label" raw="true"/></label>
>
> Nice idea, but it didn't recognize the clientId: prefix for some reason. When I changed it to its ognl equivalent (ognl:components.curRadio.clientId), this is what rendered for the first radio button:
>
> <input type="radio" name="RadioGroup" id="RadioGroup0" value="0"/>
> <label for="curChoice" id="Any_1">Yes</label>
>
> The for value does not match the radio button id. The radio button appears to be getting its id from the surrounding RadioGroup. Weird.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Radio button labels

Posted by andyhot <an...@di.uoa.gr>.
For the clientId binding prefix as well as the correct generation of ids
you need 4.1.1 or (preferably) a 4.1.2-SNAPSHOT

Robert J. Walker wrote:
> andyhot wrote:
>
>   
>> if you use
>> <div jwcid="curRadio@Radio" value="ognl:curChoice" />
>>     
>
>   
>> then 
>>     
>
>   
>> <label jwcid="@Any" for="clientId:curRadio"><span jwcid="@Insert"
>> value="ognl:curChoice.label" raw="true"/></label>
>>     
>
> Nice idea, but it didn't recognize the clientId: prefix for some reason. When I changed it to its ognl equivalent (ognl:components.curRadio.clientId), this is what rendered for the first radio button:
>
> <input type="radio" name="RadioGroup" id="RadioGroup0" value="0"/>
> <label for="curChoice" id="Any_1">Yes</label>
>
> The for value does not match the radio button id. The radio button appears to be getting its id from the surrounding RadioGroup. Weird.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
>   


-- 
Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
Tapestry / Tacos developer
Open Source / J2EE Consulting 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Radio button labels

Posted by "Robert J. Walker" <rw...@mshare.net>.
andyhot wrote:

> if you use
> <div jwcid="curRadio@Radio" value="ognl:curChoice" />

> then 

> <label jwcid="@Any" for="clientId:curRadio"><span jwcid="@Insert"
> value="ognl:curChoice.label" raw="true"/></label>

Nice idea, but it didn't recognize the clientId: prefix for some reason. When I changed it to its ognl equivalent (ognl:components.curRadio.clientId), this is what rendered for the first radio button:

<input type="radio" name="RadioGroup" id="RadioGroup0" value="0"/>
<label for="curChoice" id="Any_1">Yes</label>

The for value does not match the radio button id. The radio button appears to be getting its id from the surrounding RadioGroup. Weird.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Radio button labels

Posted by andyhot <an...@di.uoa.gr>.
if you use
<div jwcid="curRadio@Radio" value="ognl:curChoice" />

then 

<label jwcid="@Any" for="clientId:curRadio"><span jwcid="@Insert" value="ognl:curChoice.label" raw="true"/></label>




Robert J. Walker wrote:
> I'm having trouble rendering <label> tags for individual radio buttons in Tapestry 4.1. Simplified example:
>
> <div jwcid="@RadioGroup" selected="ognl:choice">
>   <div jwcid="@For" source="ognl:choices" value="ognl:curChoice">
>     <div jwcid="@Radio" value="ognl:curChoice" />
>     <span jwcid="@Insert" value="ognl:curChoice.label" raw="true"/>
>   </div>
> </div>
>
> This works fine, except that I'd like for each radio button to have a <label> tag rendered for it so that the labels are actually clickable. There doesn't seem to be a simple way to do this since the Radio component, strangely, does NOT descend from IFormComponent, so the FieldLabel component refuses to have anything to do with it.
>
> The only solution I can think of is to create my own custom component (possibly subclassing Radio) that emits the radio button AND the label. Anyone else have a better idea?
>
> Robert J. Walker
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
>   


-- 
Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
Tapestry / Tacos developer
Open Source / J2EE Consulting 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org