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

