Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JavaServer Faces » Bind <h:message> to inputText
Bind <h:message> to inputText [message #471793] Mon, 08 May 2006 08:23 Go to next message
Eclipse UserFriend
Originally posted by: crapulence.gmx.de

Hello there,

i am trying to bind an error message (required tag) to an inputText of my
form:
<h:form>
name: <h:inputText value="#{Visitor.firstname}" /><br>
surname: <h:inputText value="#{Visitor.lastname}"
></h:inputText><br>
date_of_birth: <h:inputText value="#{Visitor.birth}"
maxlength="10" size="10" required="true">
<f:convertDateTime dateStyle="short"
type="date"/>
</h:inputText>
<br><br>
<h:commandButton action="success" value="Submit" />
<h:message for "#{Visitor.birth}"/>
</h:form>

But thats not right. How to reference the field "date_of_birth" in
h:message?

Best regards,

a.k.
Re: Bind <h:message> to inputText [message #471794 is a reply to message #471793] Mon, 08 May 2006 11:56 Go to previous messageGo to next message
Yury Kats is currently offline Yury KatsFriend
Messages: 104
Registered: July 2009
Senior Member
The 'for' attribute takes a component ID, not a value of the component you want to use.

Therefore, you need to give your inputText an ID (it's a good idea to have IDs on all
components, otherwise JSF will create them for you, which sometimes causes problems):

<h:inputText id="dateOfBirth" value="#{Visitor.birth}" maxlength="10" size="10" required="true">
....
</h:inputText>

and then use that ID on the message:

<h:message for="dateOfBirth"/>


Hope this helps.

PS: This is a generic (and very basic) "how to" JSF question, not related to the JSF tooling project
this newsgroup is dedicated to. It would be appropriate in a generic JSF forum, such as
http://forum.java.sun.com/forum.jspa?forumID=427
Re: Bind <h:message> to inputText [message #471795 is a reply to message #471794] Mon, 08 May 2006 13:05 Go to previous message
Eclipse UserFriend
Originally posted by: crapulence.gmx.de

Hi Yury Kats,

thanks for your help. And thanks also for your hint relating to the
newbe-forum. I will try it there for the moment.

Best regards,

a.k
Re: Bind <h:message> to inputText [message #600339 is a reply to message #471793] Mon, 08 May 2006 11:56 Go to previous message
Yury Kats is currently offline Yury KatsFriend
Messages: 104
Registered: July 2009
Senior Member
The 'for' attribute takes a component ID, not a value of the component you want to use.

Therefore, you need to give your inputText an ID (it's a good idea to have IDs on all
components, otherwise JSF will create them for you, which sometimes causes problems):

<h:inputText id="dateOfBirth" value="#{Visitor.birth}" maxlength="10" size="10" required="true">
....
</h:inputText>

and then use that ID on the message:

<h:message for="dateOfBirth"/>


Hope this helps.

PS: This is a generic (and very basic) "how to" JSF question, not related to the JSF tooling project
this newsgroup is dedicated to. It would be appropriate in a generic JSF forum, such as
http://forum.java.sun.com/forum.jspa?forumID=427
Re: Bind <h:message> to inputText [message #600349 is a reply to message #471794] Mon, 08 May 2006 13:05 Go to previous message
Eclipse UserFriend
Originally posted by: crapulence.gmx.de

Hi Yury Kats,

thanks for your help. And thanks also for your hint relating to the
newbe-forum. I will try it there for the moment.

Best regards,

a.k
Previous Topic:Bind <h:message> to inputText
Next Topic:JSF Tools Project Milestone RC2 build posted..
Goto Forum:
  


Current Time: Tue Nov 25 22:33:48 GMT 2014

Powered by FUDForum. Page generated in 0.01698 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software