Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Immediate=True

 
jeff rusty
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to JSF and i have a problem with the immediates set to true when set on two components inside my form. I have huge datacapture form which has two dynamic select box and both has attribute required set to true and a corresponding listener.

when i do an onchange of the first select box i have to retrieve it sub elements and show it in another select box and this happens, at the same time only for the second select box which has immediate set to true the validation happens and it throws the error message saying "Field is required" whereas other non-immediate fields doesnt show error.

how to avoid this?

Also after saving the records i am showing a save message in the create screen subsequently if the user doesnt give data for mandatory field and saves, it shows error message "required"(which is correct) but at the same time my save message is also appearing. how to remove the save message when error occurs..I am doing a client side validtion in this case.

please help,
jeff
 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove the required attribute from the second element and check for the selection in the bean itself at the time of final action. This way you can customize the priority of the validations.
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a extremely annoying shortfall in the JSF specification, making immediate=true fields incompatible with validation. Unfortunately it is 'as per specification'. As a consequence I tend to only use immediate=true if I have no validation, or for cancel buttons.

One thing I have used in place of immediate=true is an Ajax call to refresh the other elements when a list box is selected.

There are many options and frameworks to make the Ajax/JSF call, and have Ajax communicate with your backing bean in a JSF compatible way.

Hope this helps.
Bob
 
jeff rusty
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Thanks for your response.
Can you give some samples for integration of JSF and AJAX with backing bean?

Thanks,
Jeff
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic