validation message is not disappear

UI Components for JSF
Post Reply
wangyu_937
Posts: 4
Joined: 19 Dec 2011, 11:02

19 Dec 2011, 11:43

Add and update using the same dialog box.
When you click Add, pop-up dialog. Input form element, when the validation fails, directly close the dialog box. Then click the Update button, verify the information still exists.

Code: Select all

<h:form id="queryForm" prependId="">
<p:dataTable id="dataTable" var="saleinfo" widgetVar="dataTableWidget" emptyMessage="#{i18n['info.norecords']}"
							paginator="true" rows="#{i18n['pagination.pagesize']}" lazy="true" paginatorPosition="bottom"
							paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
							value="#{HSSaleInfo.saleInfos}" selectionMode="single" rowsPerPageTemplate="#{i18n['pagination.template']}"
							currentPageReportTemplate="(#{i18n['pagination.di']}{currentPage}#{i18n['pagination.ye']}  #{i18n['pagination.gong']}{totalPage}#{i18n['pagination.ye']})"
							rowKey="#{saleinfo.goodId}" selection="#{HSSaleInfo.editSaleInfo}">
							<p:ajax event="page" oncomplete="dataTableWidget.unselectAllRows();"></p:ajax>
							<p:column headerText="#{example['example.outputLable.goodId']}">
								<h:outputText value="#{saleinfo.goodId}" />
							</p:column>
							<p:column headerText="#{example['example.outputLable.goodName']}">
								<h:outputText value="#{saleinfo.goodName}" />
							</p:column>
							<p:column headerText="#{example['example.outputLable.goodDate']}">
								<h:outputText value="#{saleinfo.goodDate}" />
							</p:column>
							<p:column headerText="#{example['example.outputLable.region']}">
								<h:outputText value="#{ saleinfo.city == 'shanghai' ? example['example.selectOneMenu.item.shanghai'] : ( saleinfo.city == 'beijing' ? example['example.selectOneMenu.item.beijing'] : example['example.selectOneMenu.item.shenzhen'] )}" />
							</p:column>
							<p:column headerText="#{example['example.outputLable.totalNumber']}">
								<h:outputText value="#{saleinfo.totalNumber}" />
							</p:column>
							<p:column headerText="#{example['example.outputLable.prices']}">
								<h:outputText value="#{saleinfo.prices}" />
							</p:column>
						</p:dataTable>
                                            <!--           add button                  -->
						<p:commandButton value="#{i18n['button.add']}"
							action="#{HSSaleInfo.addSaleInfo}" oncomplete="openDialogWidget.show()"
							update="dialogPanel openDialog" immediate="true">
							</p:commandButton>
                                              <!--          edit button                 -->
						<p:commandButton value="#{i18n['button.edit']}" onstart="return hystone.isSelected(dataTableWidget,'#{i18n['info.selectdata']}')"
							oncomplete="openDialogWidget.show()" update="openDialog" />
						<p:commandButton value="#{i18n['button.delete']}"   onstart="return hystone.isSelected(dataTableWidget,'#{i18n['info.selectdata']}')"
							 oncomplete="confirmationWidget.show()"/>
</h:form>
first, when I click add button,Dialog (openDialogWidget) will display. We can see some form element required , only input one of them and then click save button .
system validate failure and show error messages . Then not verify input ,but close this dialog. Click edit button,that dialog display again and input value and error messages of adding are not disappear. I want form element in dialog restore initial state ,when click edit button .

Code: Select all

	
<h:form id="dialogForm" prependId="" >
		<p:dialog
			header="#{i18n['button.set']}"
			widgetVar="openDialogWidget" modal="true" visible="false" id="openDialog">
		<p:ajax process="@form" event="close"  listener="#{HSSaleInfo.reset}"></p:ajax>
				<h:panelGrid columns="3" id="dialogPanel">
					<div>#{example['example.outputLable.goodId']}:<span style="color:red;">*</span></div>
					<p:inputText id="dialogGoodId" required="true" maxlength="50"
						value="#{HSSaleInfo.editSaleInfo.goodId}"  label="#{example['example.outputLable.goodId']}"/>
					<p:message for="dialogGoodId"/>

					<div>#{example['example.outputLable.goodName']}:<span style="color:red;">*</span></div>
					<p:inputText id="dialogGoodName" required="true" maxlength="25"
						value="#{HSSaleInfo.editSaleInfo.goodName}" label="#{example['example.outputLable.goodName']}"/>
					<p:message for="dialogGoodName" />
	
					<div>#{example['example.outputLable.goodDate']}:<span style="color:red;">*</span></div>
					<p:calendar id="dialogGoodDate" readOnlyInputText="true" required="true" pattern="yyyy-MM-dd" navigator="true"
						value="#{HSSaleInfo.editSaleInfo.goodDate}" label="#{example['example.outputLable.goodDate']}"/>
					<p:message for="dialogGoodDate"/>

					<div>#{example['example.outputLable.city']}:<span style="color:red;">*</span></div>
					<p:selectOneMenu id="dialogCity" value="#{HSSaleInfo.editSaleInfo.city}" style="width:100px">
						<f:selectItem
							itemLabel="#{example['example.selectOneMenu.item.shanghai']}"
							itemValue="shanghai" />
						<f:selectItem
							itemLabel="#{example['example.selectOneMenu.item.beijing']}"
							itemValue="beijing" />
						<f:selectItem
							itemLabel="#{example['example.selectOneMenu.item.shenzhen']}"
							itemValue="shenzhen" />
					</p:selectOneMenu>
					<p:message for="dialogCity"/>

					<div>#{example['example.outputLable.totalNumber']}:<span style="color:red;">*</span></div>
					<p:inputText id="dialogTotalNumber" required="true" maxlength="10"
						value="#{HSSaleInfo.editSaleInfo.totalNumber}" label="#{example['example.outputLable.totalNumber']}">
						<f:convertNumber />
					</p:inputText>
					<p:message for="dialogTotalNumber" />

					<div>#{example['example.outputLable.prices']}:<span style="color:red;">*</span></div>
					<p:inputText id="dialogPrices" required="true" maxlength="10" 
						value="#{HSSaleInfo.editSaleInfo.prices}" label="#{example['example.outputLable.prices']}" >
						<f:convertNumber />
					</p:inputText>
					<p:message for="dialogPrices" />

					<f:facet name="footer">
						<p:commandButton value="#{i18n['button.reset']}"
							type="reset" />
						<p:commandButton value="#{i18n['button.save']}"
							action="#{HSSaleInfo.saveSaleInfo}" 
							update="dataTable dialogPanel" oncomplete="hystone.handleDialogRequest(xhr, status, args,openDialogWidget)"/>
					</f:facet>
				</h:panelGrid>
			</p:dialog>
Last edited by wangyu_937 on 20 Dec 2011, 04:44, edited 2 times in total.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

19 Dec 2011, 11:46

Hi,

This is not enough what you wrote. You should show at least your code snippet.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests