i want a solution for updating the bean values in the phase of Process Validation, i want a scenario like this..
i have to validate a input filed , for this i wrote a validation class which implement Validator interface, in this validator class the input filed value should be validae by calling webService method. Based on this valid value, i have to update the managed bean property values. here i am getting the managed bean object from the faces context object and setting the bean property values, but this updating is do in Update model values phase. But the phase is skipped from Process Validation phase to Render Response phase, So, here the values is not updating.
Please anybody give me the reason and as well as code if you have.
I'm not sure I understood all that. But don't go getting "clever" with the JSF lifecycle. It will cause you pain now and probably even more pain later.
It is extremely bad practice for validators to do anything that has side effects - that is, changes the JSF or application environment. The insertion or removal of validators should be effectively transparent to the program, except that obviously if you remove the validator, that allows bad data to proceed down the JSF lifecycle pipeline.
I'm even doubtful that you should be doing web service based validation. I prefer to keep my validators lightweight.
You should definitely not be coding property setters with side effects. You don't have any real assurance when, or how many times, the setter will be invoked. Even if you sat down and calculated all the various scenarios, it could change in a future JSF release, it's kludgy, and it goes against the spirit of what the setters are supposed to do.
Ideally, all validation could be done by validators. But then again, what you're describing doesn't sound like just validation - it's validation with side effects, and like I said, neither validators not property methods should have side effects. Some things are just better left to the action processors. For the really gnarly stuff, the action processor is the "validator of last resort". If it doesn't like the data, it has the ability to reset the propert(ies), if desired, add an error to the JSF context, and return with a "validation failure" result string so that the JSF navigator will redisplay the page (or whatever page is most appropriate). Plus, of course, action methods have free rein to invoke any web and/or database services they want, cache data, manipulate data, and, of course, invoke business logic.
An IDE is no substitute for an Intelligent Developer.
Joined: May 25, 2009
Bu i got a output, based on the webservice i am getting the values and validating and updating the fileds in a bean, its working fine and i din't get any conflicts.
Lots of things "work". It's a different matter to make them work reliably. I have a spare wheel in my car for emergencies. It's smaller than the standard wheels, designed to be lightweight, not take up much room, and be "good enough" to drive about 50 miles at a moderate rate of speed.
If, however, I were to take my car out and attempt to drive on that wheel on the Autobahn, it would probably self-destruct in a matter of minutes, wreck the car, and probably kill me.
If having something that "works" is sufficient, so be it. There is, after all a large amount of software out there that "works". On the other hand, I think we in the programming profession would probably be more respected if we did less "works" and more stuff that "works reliably".
I know that there's a lot of pressure to simply "Git 'R Dun!", but we're not doing ourselves any favors when we make ourselves look incompetent.
Viswanath why don't you do the processing in BackingBean which you are doing in the Validator? Is there something which is stopping you?
To be on the safer side what Timm says is right. I have seen a similar situation where they played with the JSF life cycle to make the page bookmark able in JSF.
Later own it became a heck and yes the whole team now has to spend 4 hours in developng and testing a page which can be easily done in 2-2.5 hours.