ResetEditableValues BeanValidation

Community Driven Extensions Project
Post Reply
gizmo1177
Posts: 29
Joined: 18 Oct 2010, 15:48

12 Apr 2012, 20:14

Our problem is not related to any primefaces components but primefaces has a (partial) solution for it :).

"The problem is, if validation was already triggered before and some input fields were invalid. The validation state remains and survives further updates. You will see then last submitted values and / or red borders surrounding PrimeFaces' form elements" (http://fractalsoft.net/primeext-showcas ... Values.jsf)

Our use case is as following:
We have an datatable on the center of the page. Selection of an row causes an update of an detail area. The detail area has multiple input fields and an "Save" Button. When the save button is clicked and BeanValidation errors occured, the fields with constraint violations will be marked. If the user selects a new row in the mastertable the content of the fields with the constraint violation will not be updated. Also add new objects etc. will not work. The states will only be cleared if a full page refresh is made.

I think pe:resetEditableValues can only be used with UICommand components. Therefore the table selection problem cannot be solved with this component. Is there another way to solve this problem?

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

12 Apr 2012, 20:40

pe:resetEditableValueHolders can be attached to any component implementing UICommand. That's right. But we intend to remove this limitation and extend this behavior in order to support p:ajax events. Look this issue please http://code.google.com/p/primefaces-ext ... tail?id=93 This should solve your problem. The issue is targeted for 0.6 release (not the upcoming 0.5).
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

gizmo1177
Posts: 29
Joined: 18 Oct 2010, 15:48

12 Apr 2012, 21:20

Thanks a lot for your fast answer. The problem is really urgent so we need a solution the next two weeks. Could you please give me a short hint if this soution will work (until pe:resetEditableValue is ready)?

1. User press save and validation errors occurs.
2. User selects a new row in the mastertable.
3. onRowSelect Event is called

-> Retrieve the "detailArea" form from FacesContext, walk recursively the component tree, identify EditableValueHolder instances and call resetValue() method if FacesContext.isValidationFailed().

It´s just an assumption. I can first try it tomorrow morning. I just want to "free" the components from validation failed state.

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

12 Apr 2012, 22:43

Everything is urgent, but you should understand, that we're working on this open source project in our free time and we don't have enterprise support. Why should we implement this feature tomorrow if we don't need it for us self? It will be implemented as planned with 0.6 release. Sorry. But you can try to do it self as you described. I would suggest you check out the project first and look into the component implementation. It's not difficult :-)

General you need to call resetValue() on all rendered compoments (which implement EditableValueHolder) in "detailArea". Do it the best in the PreRender listener. You can register an PreRenderComponentEvent with listener on "detailArea" (h:panelGroup e.g.).
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

gizmo1177
Posts: 29
Joined: 18 Oct 2010, 15:48

13 Apr 2012, 07:08

You´re right, it´s always urgent ;). Thanks again for your effort.

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

13 Apr 2012, 09:25

You can find input components in your ajax listener (on onRowSelect) with findComponent() or visitTree(). After that you can reset their values with resetValue(). I did similar thing before pe:resetEditableValueHolders. It works. Good luck.
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 “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests