I have a page with form elements that are submitted through 2 different actions that are in the same Controller. My problem is that I need it to validation differently depending on which action was triggered. One action should have every form element mandatory, while in the other, only 2 of the form elements would be mandatory.
Can you post the code and give me the problem clearly ?
Joined: Jul 14, 2009
here it is, forgive the messy codes (i didn't write them)
there's 2 h:commandButtons near the bottom of the code that trigger different actions. right now, both validate the same way since they submit the same form (all except the comments are mandatory). what i need is that if the second button ("Validate") is triggered, only the 2 t:inputFileUpload are mandatory, all else should be ignored in the validation process.
Creating two forms would probably be the easiest solution, and be less error-prone. Another way would be making all the fields optionally (required='false') except the inputFileUpload. Of course then the fields are optionally for the other button as well, but then you could manually check if the mandatory field are filled in, in the action method itself. Latter solution s a bit dirty, but might be appropriate.
Right now the solution I implemented was having all the validations done by the action. I find it dirty since we don't get to use the Validation phase of JSF and have all the validation done in the action.
Hoping to find a neater solution to the problem, if there's any. For now, the solution implemented works.