JSF executing action even with validation errors without immediate attribute.
Rapsu Rapsinen
Greenhorn
Joined: Jul 05, 2010
Posts: 3
posted
0
Is there a mechanism in JSF 1.1 to execute and action even if there are validation errors without using immediate attribute.
Lets take an example: We have a JSF page with
- One input field that is has value pointing to a Integer in a backing bean
- Table with Integer input fields pointing to List<Integer> in backing bean.
- Button to add new rows to table.
With this setup the user should be able to add new rows to the table. How ever adding new rows should be possible even if there are validation/conversion errors.
Scenario 1:
- User types "foo" to the count-field
- User presses Add Row-button
FAILURE: new row is not added because there are conversion errors on the count-field
Scenario 2:
- Add the "immediate=true" for the commandButton
- User inserts "3" for the first value field in the table.
- User presses the Add Row-button
FAILURE: New row is added but the inserted value "3" is disregarded (changes back to "0" in the page).
Applying the immediate=true for input fields would not help much as that would required adding it to all fileds in the page (including the count field). And still the Add Row-action should be executed even if there are errors on field validations/conversions.
One of the primary purposes of JSF is to ensure that invalid data doesn't get entered.
If you want to force invalid data in anyway, don't validate it.
Customer surveys are for companies who didn't pay proper attention to begin with.
Rapsu Rapsinen
Greenhorn
Joined: Jul 05, 2010
Posts: 3
posted
0
Tim Holloway wrote:One of the primary purposes of JSF is to ensure that invalid data doesn't get entered.
If you want to force invalid data in anyway, don't validate it.
Thanks for your reply Tim.
However I do not see your comment quite accurate. I am not after storing invalid data, it should not be stored to backing bean. But what I need is to fire an action without storing the data (kind of similar to what happens when user submits a page with errors: the entered invalid data is preserved).
How to refresh the page so that
- data entered by user is preserved but not validated nor stored
- action modifying the backing bean (adding row) is executed