Win a copy of Machine Learning with TensorFlow this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

JSF executing action even with validation errors without immediate attribute.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?


 
Saloon Keeper
Posts: 23295
158
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
There are no more "hours", it's centi-days. They say it's better, but this tiny ad says it's stupid:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic