2

The modules of our web application shows a datatable in the center and the detail of the selected record on the right. Every time the user selects a record of the mastertable we update the detail page and show the details of the selected record. Now we have the following problem:

  1. User selects a record in the mastertable and data is displayed in detail area.
  2. User modifies the detail data and clicks on save.
  3. An validation(bean validation) error occurs and the user will see the error msg).
  4. Instead of correcting the wrong input the user selects another record of the mastertable.
  5. All fields that have no error state will be updated with the data of the new record. The fields that are wrong before shows the old data. The data of the old record stays until the user makes a page refresh.

Is there any way to solve this problem? I've seen a pe:resetInput component from Primefaces extensions but this component needs a UICommand component to work. I need a solution that works if the user selects another entry of the mastertable.

siebz0r
  • 18,867
  • 14
  • 64
  • 107

1 Answers1

2

You can use the ResetInputAjaxActionListener of OmniFaces for this. Apart from being registered as a <f:actionListener>, it can also be globally registered as a PhaseListener.

See also:


If you intend to take it in your own hands, then you basically need to write code yourself which does basically the following things:

  • During the invoke action phase, get to-be-rendered UIInput components which are not been executed/processed by the ajax request.
  • Invoke resetValue() method on them.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • One more Question. The component works as expected and the fields will be reset but since my change tags doesn´t work anymore. It seems that they will be ignored. Could this belong to the ResetInput component? (JSF lifecycle) –  Jul 18 '12 at 12:38
  • What exactly are you usuing them for? To build the view? Or to render the view? If the latter, then it was the wrong tool. See also http://stackoverflow.com/questions/3342984/jstl-in-jsf2-facelets-makes-sense – BalusC Jul 18 '12 at 12:45
  • We use it to build the view. Here´s an simple example: In firebug I see that something went completely wrong. The logic tries to access properties ofwrong beans and so on. I´ve tested several places where we use . It doesn´t work anymore. If I remove the ActionListener everything is ok. –  Jul 18 '12 at 13:00
  • This is strange. It would be helpful if you report an issue along with an SSCCE. – BalusC Jul 18 '12 at 13:42