You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Locke, Richard" <ri...@fairisaac.com> on 2006/05/11 16:20:25 UTC

t:outputLabel for attribute and forceId="true"

Hi All,

I am creating a simple form using label tags to help with accessibility.
I want to force the ids not to have the form prefixed so I can do more
client-side coding (CSS, DOM, JavaScript etc).

Here is a simple code fragment.
  <t:outputLabel for="txtInputText" id="lblInputText" value="Label text"
forceId="true"/>
  <t:inputText id="txtInputText" value="Input text" forceId="true"/>

When this code fragment is rendered to a browser, I get the following
HTML result:
  <label id="lblInputText" for="form:txtInputText">Label Text</label>
  <input id="txtInputText" name="txtInputText" type="text" value="Input
text" />

That's all fine except that the label's for attribute has the 'form:'
prefix. Why? I would not think that <t:outputLabel> tag would know
anything about the rest of the page.

If I swap the lines around like so:
  <t:inputText id="txtInputText" value="Input text" forceId="true"/>
  <t:outputLabel for="txtInputText" id="lblInputText" value="Label text"
forceId="true"/>

I get the following HTML result:
  <input id="txtInputText" name="txtInputText" type="text" value="Input
text" />
  <label id="lblInputText" for="txtInputText">Label Text</label>

That is how I want to label's for attribute to look like. Does anyone
know how I can get this result if the label is defined before the input
tag when forceId="true"?


Thanks in advance.

Rich
This email and any files transmitted with it are confidential, proprietary
and intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.


Re: t:outputLabel for attribute and forceId="true"

Posted by Matthias Wessendorf <ma...@apache.org>.
Rich-

the ADF form component might be interesting to you too.
It is not a naming container (like h:form).

  <h:form id="foo">
   <!-- This inputText will have a rendered id of "foo:bar" -->
   <af:inputText id="bar"/>
  </h:form>

  <af:form id="foo2">
   <!-- This inputText will have a rendered id of just "bar2" -->
   <af:inputText id="bar2"/>
  </af:form>

If you are interested, I'd like to invite you to the adf related
mailing lists ;)

-Matthias


On 5/11/06, Locke, Richard <ri...@fairisaac.com> wrote:
> Hi Matthias,
>
> Thanks for the very useful article. The solution was there on the first
> page!
> The <h:panelGroup> tag does the job perfectly.
>
> Rich
>
> -----Original Message-----
> From: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] On Behalf Of
> Matthias Wessendorf
> Sent: 11 May 2006 16:02
> To: MyFaces Discussion
> Subject: Re: t:outputLabel for attribute and forceId="true"
>
> > That's all fine except that the label's for attribute has the 'form:'
> > prefix. Why? I would not think that <t:outputLabel> tag would know
> > anything about the rest of the page.
>
> That is a "problem" of JSF 1.1 spec
>
> <t:outputLabel /> (or h:outputlabe) BEFORE an input won't work
>
> since the label doesn't know the rest of the page
>
> see [1] for lot's of informations on that
>
> -Matthias
>
> [1] http://www.onjava.com/pub/a/onjava/2004/06/09/jsf.html
> This email and any files transmitted with it are confidential, proprietary
> and intended solely for the individual or entity to whom they are addressed.
> If you have received this email in error please delete it immediately.
>
>


-- 
Matthias Wessendorf
Aechterhoek 18
48282 Emsdetten
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

RE: t:outputLabel for attribute and forceId="true"

Posted by "Locke, Richard" <ri...@fairisaac.com>.
Hi Matthias,

Thanks for the very useful article. The solution was there on the first
page!
The <h:panelGroup> tag does the job perfectly.

Rich

-----Original Message-----
From: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] On Behalf Of
Matthias Wessendorf
Sent: 11 May 2006 16:02
To: MyFaces Discussion
Subject: Re: t:outputLabel for attribute and forceId="true"

> That's all fine except that the label's for attribute has the 'form:'
> prefix. Why? I would not think that <t:outputLabel> tag would know 
> anything about the rest of the page.

That is a "problem" of JSF 1.1 spec

<t:outputLabel /> (or h:outputlabe) BEFORE an input won't work

since the label doesn't know the rest of the page

see [1] for lot's of informations on that

-Matthias

[1] http://www.onjava.com/pub/a/onjava/2004/06/09/jsf.html
This email and any files transmitted with it are confidential, proprietary
and intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.


Re: t:outputLabel for attribute and forceId="true"

Posted by Matthias Wessendorf <ma...@apache.org>.
> That's all fine except that the label's for attribute has the 'form:'
> prefix. Why? I would not think that <t:outputLabel> tag would know
> anything about the rest of the page.

That is a "problem" of JSF 1.1 spec

<t:outputLabel /> (or h:outputlabe) BEFORE an input won't work

since the label doesn't know the rest of the page

see [1] for lot's of informations on that

-Matthias

[1] http://www.onjava.com/pub/a/onjava/2004/06/09/jsf.html