Two Laptop Bag
The moose likes JSF and the fly likes JSF executing action even with validation errors without immediate attribute. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "JSF executing action even with validation errors without immediate attribute." Watch "JSF executing action even with validation errors without immediate attribute." New topic
Author

JSF executing action even with validation errors without immediate attribute.

Rapsu Rapsinen
Greenhorn

Joined: Jul 05, 2010
Posts: 3
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.

Backing bean:


JSP:


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.

Any ideas how to solve the problem?


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14460
    
    7

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
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel/download
 
subject: JSF executing action even with validation errors without immediate attribute.
 
Similar Threads
Unable to call Action Methof
How to display custom message for inputText field of integer type
How can I refresh(reset) inputText in a dataTable?
Input text in each row of JSF datatable not getting updated while submitting
JSF clear fields on validation errors