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