Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF executing action even with validation errors without immediate attribute.  RSS feed

 
Rapsu Rapsinen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rapsu Rapsinen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!