• Post Reply Bookmark Topic Watch Topic
  • New Topic

Keep Dailog up when validation fails after submit using jsf primefaces

 
Baazi Reddy
Greenhorn
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"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:p="http://primefaces.org/ui">
<ui:define name="head">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<f:metadata>
<f:event type="preRenderView" listener="#{loginBean.validuser}" />
</f:metadata>


</ui:define>

<ui:define name="body">
<center>

<h:form id="form">

<!-- <p:growl id="growl" showDetail="true" />
-->
<p:dataTable id="dataTable" var="country"
value="#{countryBean.countriesList}"
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">
<p:column>
Click the button to add new Country :
</p:column>
<p:column>

<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;"
value="#{countryBean.countryMaster.countryCode}"
required="true" label="Code">
<f:validateLength minimum="2" />
</p:inputText>
<p:message for="Code" display="icon" />

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

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

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

</p:column>
</f:facet>

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

<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>

<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" />


</p:column>
</p:dataTable>
</h:form>

</center>
</ui:define>

</ui:composition>




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

Thanks In Adavance.

Baazi.
 
Tim Holloway
Bartender
Posts: 18412
58
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!