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

Validation issues for h:inputText  RSS feed

 
Radu Mircea
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I have two h:inputText controls. I write a piece of code which copy content of first input to second one.

Now after i added validation for these inputs (rich:bean validator) that "copy action" is not working anymore , i added immediate="true" for this controls but it seems to be pointless, the action copy is never executing now.

It seems that validation is triggered before the "copy action" to have place, and it stops everything but even if i fill inputs with valid values the action also does not perform.

Please if you have an idea about this behavior give me an hand !

Thanks,
Radu
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A fundamental rule about JSF is that it doesn't want to allow you to update a bean with bad data. All the data has to be good (according to the validation constraints you set) or none of the data in that form will be updated. Data outside that form isn't even sent to the server.

It sound like you're getting an error, but not an error message. Add the "h:messages" tag to the page and that may help.
 
Radu Mircea
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Thanks for your message.

Yes , invalid data cases this behavior, but somehow i need to pass the validation and let the beans to be filled. Something like on ajax request fill beans even with worse data, and on submit validate.

Regards,
Radu

 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, like I said:

A fundamental rule about JSF is that it doesn't want to allow you to update a bean with bad data.

Which means that you're going to have to re-examine how you define data as bad. There are basically only 2 options.

1. Remove the validators that cause the lifecycle to abort.

2. Remove the property updates that will fail validation from the submitted form. If they're not submitted, they're not validated. If they're not validated, they can't fail validation. If they don't fail validation, they don't suppress the Update Data JSF lifecycle step.

You can accomplish item #2 using AJAX. Item #1 is just a matter of removing the validators from the view definition.
 
Radu Mircea
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !

Thanks again for posting and helping !

Yes now is more clear...

Regards,
Radu
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!