Validation messages are displaying at the bottom of the page JSF - javax faces developmentstage messages -
i stuck displaying error message in jsf. requirement given below:
i have user form, user has enter details firstname, lastname, username , emailaddress. these fields mandatory, among these fields, username , emailaddress unique. when user enters fields, , if clicks save @ backend have check whether username , email address exists in db, if exists have show error message on top of page saying "the data entered exists, please reenter again".
and validation messages firstname , lastname should display on side of each field. can't use <h:messages>
because displays validation messages @ once.
so populating hidden field in form message using following code:
context.addmessage("addusererrormessage", new facesmessage("the data entered exists, please reenter again"));
addusererrormessage
id of hidden form field.
but when displaying message @ top of page
<h:message for="adduserformmessage">
the message being displayed @ bottom of page when inspect through firebug, found following tags populating
<ul id="javax_faces_developmentstage_messages" title="project stage[development: unhandled messages"> <li style="color:red;">the data entered exists, plese reenter again </li> </ul>
i not able find out, why message showing @ bottom, written <h:message>
tag of top of page.
can 1 me on this?
thanks in advance
so populating hidden field in form message using following code:
context.addmessage("addusererrormessage", new facesmessage("the data entered exists, please reenter again"));
addusererrormessage id of hidden form field.
the addmessage()
expects client id first argument, not component id. client id should formid:addusererrormessage
. client id html dom element id. open page in browser, rightclick it, view source, locate hidden input , figure id
attribute.
as different (and more commonly used) alternative, don't abuse hidden input, set null
client id:
context.addmessage(null, new facesmessage(message));
this way message set global message , can use globalonly
attribute of <h:messages>
display global messages only.
<h:messages globalonly="true" />
Comments
Post a Comment