That would be fine if the label actually preceded the set of radio buttons.
Each one of my radio buttons has a label and I want to tie these labels to
each of their respective buttons via the "for" attribute.

 

In my bean class, I specify the label by instantiating a set of SelectItem()
classes and passing in the label.

 

Behind the scenes, the JSF renderer surrounds the <input type=radio..> with
<label> tags.

 

 

 

  _____  

From: Grant Smith [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 08, 2007 5:09 PM
To: MyFaces Discussion
Subject: Re: jsf 508 accessibility requirement satisfaction and use of
<label for=..> tag.

 

<h:outputLabel for="foobar" value="Select one of:"/>

<h:selectOneRadio id="foobar" value="#{BeanName.readioButtonSelected}">
       <f:selectItems value="#{ BeanName.radioButtonList}"/>
</h:selectOneRadio>

On 2/8/07, Nael Ramadan <[EMAIL PROTECTED] > wrote:

Anyone else have an insight on this issue?


-----Original Message----- 
From: Nael Ramadan [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 06, 2007 5:56 PM
To: 'MyFaces Discussion'
Subject: RE: jsf 508 accessibility requirement satisfaction and use of 
<label for=..> tag.

Maybe I have not explained myself correctly.  What if I am doing this:

<h:selectOneRadio value="#{BeanName.readioButtonSelected}">
        <f:selectItems value="#{ BeanName.radioButtonList}"/>
</h:selectOneRadio>


What you are suggesting below, will not work unless I misunderstood again.




-----Original Message-----
From: Simon Kitching [mailto: [EMAIL PROTECTED]
Sent: Tuesday, February 06, 2007 5:34 PM
To: MyFaces Discussion
Subject: Re: jsf 508 accessibility requirement satisfaction and use of
<label for=..> tag. 

When you get a reply you should really read it properly.

As I said, and as described here, a label tag can wrap another tag in
which case "for" is not needed:
   http://www.w3schools.com/tags/tag_label.asp

<label>
   a label
   <input type="checkbox" name="cb1">
</label>

<div>
   just some text
   <input type="checkbox" name="cb2"> 
</div>

Clicking on the text "a label" will toggle the checkbox, ie the text
really is a label. Clicking on "just some text" will NOT toggle the
checkbox.

However if you want a label that is not adjacent to the input control, 
then do:
  <h:inputText id="input1" .../>
  some other stuff
  <h:outputLabel for="input1" value="labeltext"/>

See also:
     <http://www.nabble.com/How-to-reply-to-emails-tf3182877.html>
http://www.nabble.com/How-to-reply-to-emails-tf3182877.html

Nael Ramadan wrote:
> The "for" attribute enables the target component to be selected via its
> label.  For example:
>
> <hr>Select Type version of MyFaces </hr>
> <label for="comp_id1">Version 1</label><input type="radio"
name="comp_id1">
> <label for="comp_id2">Version 2</label><input type="radio" 
name="comp_id2">
> <label for="comp_id3">Version 3</label><input type="radio"
name="comp_id3">
>
> By clicking on "Version 1" label, the radio button (with name = comp_id1 )

> is selected.
>
> By clicking on "Version 2" label, the radio button (with name = comp_id2 )
> is selected.
>
> By clicking on "Version 3" label, the radio button (with name = comp_id3 )

> is selected.
>
>
> This is for html.  By definition, a label serves no purpose without its
for
> attribute.
>
> How can this be done in JSF?
>
>
>
>
> -----Original Message-----
> From: Simon Kitching [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 06, 2007 2:57 PM
> To: MyFaces Discussion
> Subject: Re: jsf 508 accessibility requirement satisfaction and use of
> <label for=..> tag.
>
> Nael Ramadan wrote:
>> 1.
>>
>> Dear listner,
>>
>> My JSF pages must satisify 508 accessibility requirement through the use 
>> of the html label tag.
>>
>> In html, you wrap the html component (i.e. <input type=radio
>> id="id_name" ..>) with the <label for="id_name"> .. </label> tag where 
>> the "id" links the label with the component.  This allows ease of
>> selection where users would just have to click on the label of the html
>> component in order to select the component. 
>>
>> So how is this achieved in JSF?
>>
>> When JSF renders an html equivalent components (i.e.
>> h:selectOneRadioButton) into html, the component is surrounded
>> automatically with <label>..</label> tag but without the "for" attribute.

>>
>> How can I get around this issue such that I can control the <label> and
>> not the JSF rendering engine?
>>
>> I tried surrounding the component with <h:outputLabel for=..> .. 
>> </h:outputLabel> but JSF pretty much seems to ignore it.
>>
>> Do I need to create my own custom JSF component?
>>
>
> When a <label> tag *wraps* am HTML tag then there is *no need* for a 
> "for" attribute - the tag the label refers to is obvious. This is
> standard HTML, not JSF-specific. I'm sure your 508 spec does NOT require
> the "for" attribute if the label tag wraps the target tag. 
>
> If the label tag cannot wrap its target tag for any reason, then (and
> only then) the "for" attribute is needed.
>
> http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/tlddocs/index.html
>
> Regards,
>
> Simon
>




-- 
Grant Smith

Reply via email to