Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #3160
| From | Lew <noone@lewscanon.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: JSF label doesn't render |
| Date | 2011-04-20 09:00 -0400 |
| Organization | albasani.net |
| Message-ID | <iomldn$dq2$1@news.albasani.net> (permalink) |
| References | <iol3hd$559$1@dont-email.me> <iolu52$uv$1@dont-email.me> |
Travers Naran wrote:
>> Hi all, I've got a weird problem with JSF rendering. For some reason,
>> the label attribute doesn't want to render on the resulting HTML output.
>> For example, if I have this:
>>
>> <h:inputText label="First Name"
>> id="fname"
>> required="true" />
>>
>> That label, "First Name", never shows up on the HTML. I checked the HTML
>> source too and it's not there, so it's not a browser problem per se.
You should read the tutorial, you should read the taglib docs, and you should
read the other JSF docs on this tag. That would illuminate your error. RTFM.
(Links provided in this post.)
> Unless this is something new in JSF 2, there is no "label" attribute on
> inputText. In JSF 1.2, you do something like this:
Nope. According to
<http://download.oracle.com/javaee/5/javaserverfaces/1.2/docs/tlddocs/h/inputText.html>
there is, too, a "label" attribute for 'h:inputText'. It is described as a
"localized user presentable name for this component". However, it is NOT the
same as an HTML 'label' tag, nor a JSF 'h:outputLabel' tag. There's no reason
to expect to see it in the HTML at all whatsoever, which is why the OP does
not see it.
The Java EE 6 tutorial at
<http://download.oracle.com/javaee/6/tutorial/doc/bnarf.html#bnarr>
presents the 'h:inputText' tag with a "label" attribute in the very first example:
>> <h:inputText id="name" label="Customer Name" size="50"
>> value="#{cashier.name}"
>> required="true"
>> requiredMessage="#{customMessages.CustomerName}">
>> <f:valueChangeListener
>> type="com.sun.bookstore6.listeners.NameChanged" />
>> </h:inputText>
>>
>>
>> The label attribute specifies a user-friendly name that will be used in the
>> substitution parameters of error messages displayed for this component.
This description, however, does not match the OP's intended use. Maybe he
should read the tutorial and other JSF docs?
For example:
<http://download.oracle.com/docs/cd/E17802_01/j2ee/javaee/javaserverfaces/2.0/docs/pdldocs/facelets/h/inputText.html>
describes the "label" attribute of 'h:inputText' as "A localized user
presentable name for this component". There's nothing there to imply anything
emitted in HTML for it.
Contrast with how the tutorial describes the 'h:outputLabel' tag:
"The h:outputLabel tag is used to attach a label to a specified input field
for the purpose of making it accessible."
> <h:outputLabel value="First Name" for="fname"/>
> <h:inputText id="fname" value="#{BackingBean.Property}" required="true"/>
This will provide his intended use. Note that in HTML, "label" is not an
attribute of the 'input' tag, but a separate tag in its own right. There is
no "label" attribute in HTML for the 'input' tag.
So, bottom line: The 'h:inputText' attribute "label" is not intended to
generate any HTML, that's why you don't see it.
RTFM.
--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
JSF label doesn't render markspace <-@.> - 2011-04-19 15:49 -0700
Re: JSF label doesn't render Travers Naran <tnaran@gmail.com> - 2011-04-19 23:23 -0700
Re: JSF label doesn't render Lew <noone@lewscanon.com> - 2011-04-20 09:00 -0400
Re: JSF label doesn't render markspace <-@.> - 2011-04-20 13:01 -0700
Re: JSF label doesn't render Lew <noone@lewscanon.com> - 2011-04-20 22:47 -0400
Re: JSF label doesn't render markspace <-@.> - 2011-04-21 11:09 -0700
Re: JSF label doesn't render Esmond Pitt <esmond.pitt@bigpond.com> - 2011-04-20 22:13 +1000
Re: JSF label doesn't render Roedy Green <see_website@mindprod.com.invalid> - 2011-04-20 14:00 -0700
Re: JSF label doesn't render Lew <noone@lewscanon.com> - 2011-04-20 22:51 -0400
csiph-web