Clearing p:messages

UI Components for JSF
Post Reply
neliel123
Posts: 5
Joined: 17 May 2012, 12:13

21 May 2012, 07:37

Hi,

I am doing CRUD functionality using dialogs and I have added the p:messages on top to display messages

If validation fails for example the required property when user clicks save, it is being shown at the p:messages.

Code: Select all

<p:dialog id="addMemberDialog" header="Member Details"
	widgetVar="addMemberDlg" resizable="false" closable="false"
	modal="true">
	<p:messages id="createupdateformmessages" />
	<h:form id="createupdateform">
		<p:panelGrid columns="2" id="panel">
			<f:facet name="header">
				Create Member
			</f:facet>
			<h:outputLabel value="First Name:" for="firstName" />
			<p:inputText label="First Name" id="firstName" title="First Name"
				required="true" value="#{memberManagedBean.newMember.firstName}">
			</p:inputText>
			<!-- More Code here -->
			
			<f:facet name="footer">
				<p:commandButton value="Save"
					update=":memberListForm:membersTable createupdateform :createupdateformmessages"
					process="@form" />
				<p:commandButton value="Cancel" immediate="true" process="@this"
					oncomplete="addMemberDlg.hide()" />
			</f:facet>
		</p:panelGrid>
	</h:form>
</p:dialog>
My question is this, is it possible to remove the p:messages messages when the user starts filling at least one field with error in validation with data?
Suppose I have First Name/Middle Name/Last Name as failed in validation of 'required' and so when I start typing at the first name field then the p:messages should disappear.

What happens right now is that the p:messages is shown even if I start filling the input text with data which is the default functionality?

Primefaces 3.2

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

21 May 2012, 18:04

1. use jquery/javascript solution
2. assign id="..." to your p:messages UI component
3. onkeydown or onkeyup event of your p:inputText, call javascript/jQuery method or script to hide or display = none on the p:messages ID.
4. Search stackoverflow.com for javascript/jquery 'script' to hide content on your xhtml page

This is just a quick guess, or i'm shooting from the hip with this recommended solution for you. :)
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: eeveez and 54 guests