I have noticed a strange behavior (maybe bug?) that happens when displaying a faces view state after executing a transition with no target (event handler). The result is that the user interface displays stale data and is inconsistent with the model.
STEPS TO REPRODUCE
=================
I have a view state which presents a form. No ajax is used. The view state has a transition with no target (event handler) that is executed when the form is submitted.
1) Fill out every field in the form. In one of the fields (say field A) enter a value that will cause a conversion error. For example enter a string where a number or date is expected.
2) Submit the form. The screen loads again showing all the fields as entered. The conversion error is reported for field A.
3) Now fix field A where the conversion error happened but also change a valid field (say field B) to a different valid value.
4) The form is submitted successfully, the transition executes, actions are called, etc, etc. The model is updated with the correct values for fields A and B. Because the transition has no target the same view is displayed again. THE PROBLEM IS: field B shows the previous value, which is the value that was entered during the first submission of the form!
COMMON SCENARIO
================
This scenario is quite common in search by criteria screens where the results are displayed on the same screen. The event handler executes the search and the same view state is displayed with the search results.
BOOKING-FACES SAMPLE
===================
I have made a few modifications to the swf-booking-faces sample code to reproduce this issue. Just replace the files booking-flow.xml and enterBookingDetails.xhtml with the ones I have attached below. Try to book a hotel. In the enter booking details screen, enter a non valid string for "check-in date". Submit the form. A validation error is displayed. Then enter a valid value for the "check-in date" but change another field, say "Credit card name" to another valid value. Submit the form. You will notice that "Credit card name" displays its previous value.
DEBUGGING
=========
From a little debugging I did, I think the sequence of events that causes this behavior is the following:
form is filled (includes a field value that will cause a conversion error) and submitted
component tree is updated with submitted values
processing stops because of conversion error
component tree state is saved (the saved state includes the field values that were submitted and converted successfully - set as component "local values")
view is displayed
(all the above is within a single request - response)
form is filled and submitted with valid but different values
component tree state is restored (includes previous local values of valid fields)
component tree is updated with new submitted values
processing completes successfully
a redirect command is returned to the client (because of the POST-REDIRECT-GET idiom)
the client sends a GET request for the same view
component tree state is restored as it was last saved (previous local values!!)
the view is rendered with incorrect values
I noticed this behavior some time ago in version 2.0.3 but it hasn't changed in 2.0.4 either. I see 2.0.5 is also out now. If this turns out to be a bug, I hope I didn't report it too late to be addressed before 3.0.0.
Thanks for reading!


Reply With Quote
