• Post Reply Bookmark Topic Watch Topic
  • New Topic

Keep Dailog up when validation fails after submit using jsf primefaces  RSS feed

Baazi Reddy
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My requirment is Iam displaying employee details in datatable. on top there is menu button "Add Employee". when user clicks add employee Dailog box opens where he can enter employee deatils and submit it. If there is a validation errors Dailog box sholudn't close after button click.

And code is :

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="layout.xhtml"
<ui:define name="head">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<f:event type="preRenderView" listener="#{loginBean.validuser}" />


<ui:define name="body">

<h:form id="form">

<!-- <p:growl id="growl" showDetail="true" />
<p:dataTable id="dataTable" var="country"
emptyMessage="No data found with given Data"
filteredValue="#{countryBean.filter}" style="font-size: 12px;"
resizableColumns="true" liveResize="true">

<!-- <p:ajax event="colResize" update=":form:growl"
listener="#{countryBean.onResize}" />
<f:facet name="header">
Click the button to add new Country :

<p:commandButton styleClass="addbutton" value="Add Country"
onclick="dlg3.show();" type="button" />

<p:dialog id="dialog" widgetVar="dlg3" showEffect="puff">
<p:panel header="Add Country Details">
<p:messages id="msgs" />
<h:panelGrid columns="3">

<h:outputLabel for="Code" value="CountryCode :*"
style="font-size: 12px;" />
<p:inputText id="Code" style="font-size: 12px;"
required="true" label="Code">
<f:validateLength minimum="2" />
<p:message for="Code" display="icon" />

<h:outputLabel for="NameAr" value="CountryNameAr :*"
style="font-size: 12px;" />
<p:inputText id="NameAr" style="font-size: 12px;"
required="true" label="NameAr">
<f:validateLength minimum="2" />
<p:message for="NameAr" display="icon" />

<h:outputLabel for="NameEn" value="CountryNameEn :*"
style="font-size: 12px;" />
<p:inputText id="NameEn" style="font-size: 12px;"
required="true" label="NameEn">
<f:validateLength minimum="2" />
<p:message for="NameEn" display="icon" />
<!-- ** -->
<h:commandButton value="Add" update="display" process="someID"

oncomplete="if (#{facesContext.validationFailed}) dlg3.show()"
style="font-size: 12px;" />


<p:column filterBy="#{country.countryCode}"
sortBy="#{country.countryCode}" headerText="CountryCode"
style="font-size: 12px;">
<h:outputText value="#{country.countryCode}" />

<p:column filterBy="#{country.countryNameAr}"
sortBy="#{country.countryNameAr}" headerText="CountryNameAr"
style="font-size: 12px;">
<h:outputText value="#{country.countryNameAr}"
style="font-size: 12px;" />

<p:column filterBy="#{country.countryNameEn}"
sortBy="#{country.countryNameEn}" headerText="CountryNameEn"
style="font-size: 12px;">
<h:outputText value="#{country.countryNameEn}"
style="font-size: 12px;" id="test" />




If any one of you provide solution with code for this problem very helpful to me.

Thanks In Adavance.

Tim Holloway
Posts: 18662
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of bold-facing your XML, try our "Code" button next time. It won't re-format your pre-formatted text.

I don't know the process for doing this in PrimeFaces, but in RichFaces, it's fairly tricky and involves using the JSON data passback and a certain amount of client-side JavaScript code.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!