0

In my application I placed a <p:panel> in a <h:form>. Now in this panel I have some <p:inputText> and at the end of panel I have two button one is Submit another is Reset. Reset button works properly if it is pressed before submit the form. But if Once I submit the form and some text fields fails to validate then that fields are containing the previous entered data. Now if I press Reset button to clear all the fields then it is not working.

My Reset button's code :

<p:commandButton value="#{Bundle['resetButton']}" process="@this" update="addCustomerPanel" immediate="true" />

The form is like :

<h:form id="customerForm">
    <p:panel id="addCustomerPanel">

            .......text fields and two buttons placed here

            </p:panel>
<h:form>

Update I have solved this problem by navigate to the same page on reset button click.

Diganta
  • 671
  • 3
  • 11
  • 27
  • This is almost the same : http://stackoverflow.com/questions/6062923/how-to-skip-validation-when-a-specific-button-is-clicked You can try using plain JSF h:commandButton – Alexandre Lavoie May 17 '13 at 13:24
  • 1
    @Alexandre Lavoie:Thanks for reply, but my problem is not the same with given link provided by you. My problem is after form submition(when form is not submitted due to validation error of some fields) if I press `Reset` button to clear all the fields,then `Reset` button is not works. But in that link solution is given how to skip field validation during `cancel` button press. – Diganta May 17 '13 at 13:50
  • I suggest you use javascript to reset the fields because doing a navigation is slower (page has to be reloaded) – damian May 17 '13 at 15:09
  • In your code you have just proceed the button only, so whether you are providing immediate or not it will not have any issue. As the validation is happens if you are processing particular component having validator. So you just need to reset the components on that button's Business logic and update that component. e.g. for inputText you can write txt=null; – Jitesh May 18 '13 at 10:32
  • @Jitesh: Thank you for reply, I tried this. I have a `DTO` object corresponding to this form. In `Reset` button's action method I set all properties of `DTO` null. The form is not refreshing(After once pressing submit button and not submit for validation error). i.e view is not refreshing. – Diganta May 19 '13 at 05:23

0 Answers0