aspose file tools*
The moose likes JSF and the fly likes  Immediate=True Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark " Immediate=True" Watch " Immediate=True" New topic
Author

Immediate=True

jeff rusty
Ranch Hand

Joined: Nov 07, 2006
Posts: 109
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

Joined: Aug 18, 2008
Posts: 598

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.


My Blog SCJP 5 SCWCD 5
Bob Good
Ranch Hand

Joined: Jan 09, 2008
Posts: 86
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

Joined: Nov 07, 2006
Posts: 109
hi,
Thanks for your response.
Can you give some samples for integration of JSF and AJAX with backing bean?

Thanks,
Jeff
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Immediate=True