I am using <p:dialog>
to add a new row to <p:dataTable>
taking input from user, but I am unable to reset it. Everytime it shows data of previous input and instead of adding it's editing the current row. How do I clear the fields?
<h:form id="foodTableForm">
<p:dataTable id="foodTableId" var="v" value="#{dashboardBean.myFoodList}" editable="true">
<p:ajax event="rowEdit" listener="#{dashboardBean.onEdit}" />
<p:ajax event="rowEditCancel" listener="#{dashboardBean.onCancel}" />
<p:column sortBy="#{v.project}" headerText="Project Name">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{v.project}" />
</f:facet>
<f:facet name="input">
<p:inputTextvalue="#{v.project}"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="#{msg['product.label.edit']}">
<p:rowEditor />
</p:column>
<p:column headerText="#{msg['product.label.delete']}">
<p:commandLink id="deleteFoodPromotion" actionListener="#{dashboardBean.deleteFoodPromotion(v)}" update="@form" />
</p:column>
</p:dataTable>
</h:form>
<h:form id="dialogInputForm">
<p:dialog widgetVar="dlg">
<p:inputText id="firstname" value="#{dashboardBean.foodPromoDTO.project}" required="true" />
<p:calendar value="#{dashboardBean.foodPromoDTO.promoDate}" id="startDate" required="true" />
<h:selectOneMenu value="#{dashboardBean.foodPromoDTO.action}" required="true">
<f:selectItem itemLabel="Promo Start" itemValue="Promo Start" />
<f:selectItem itemLabel="Promo End" itemValue="Promo End" />
</h:selectOneMenu>
<p:commandLink id="submitButton" value="Save" action="#{dashboardBean.addFoodPromotion}" update="@form" oncomplete="PF('dlg').hide();" />
</p:dialog>
</h:form>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…