This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Ajax call, backing bean and validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Ajax call, backing bean and validation" Watch "Ajax call, backing bean and validation" New topic
Author

Ajax call, backing bean and validation

Tommaso Tama
Greenhorn

Joined: Oct 13, 2010
Posts: 11
Hi to all, here I'm again!

After running around and crawling the web, I have my main issue back again on my desk.
Please, help me to undertand if there is a solution to my ancient problem.

The scenario in quite simple:

- jsf 1.2
- richfaces
- ajax


Two required input text, rollo and job1.
An a4j:commandButton that updates the value oh the backing bean property linked to rollo input text.




It works fine: the button updates the backing bean and the input text on the page shows the updated value.
BUT when I submit the form and I trigger a validation error of a component JOB1 on the, the a4j:commandButton updates only the backing bean and not the field on the page. Indeed, if the component with validation problem is the one designed to be updated by the ajax call, IT WORKS. But if ANY other component is invalid, the ajax button can update only the backing bean and not the component. Maybe after the submit something happens that block the update. Losing my head, sorry.

is there a logic reason for that behaviour? Is there a workaround?

Many thanks!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

JSF does not permit partial updating of a bean where only valid items update. If any item selected for update is invalid, the backing bean will not be updated.

Normally, that means all property references on the submitted form. When using AJAX (a4j), you can limit the properties that are submitted/validated if you desire. However, you have not done this, so all properties will be submitted and subjected to validation.

When a backing bean property is updated using a4j, its value will only update on the View if the id of the control that displays its value has been included in a reRender request.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ajax call, backing bean and validation
 
Similar Threads
Validation Problem ... again!
Ajax status doesn't stop in IE8
how to skip validation phase only
Problem with h:message and richfaces
File browser button