Forums Register Login

validating a form being submitted by 2 actions

+Pie Number of slices to send: Send
Hi guys,

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.

Is there a way to implement this in JSF?

Thanks,
Marlon
+Pie Number of slices to send: Send
Can you post the code and give me the problem clearly ?
+Pie Number of slices to send: Send
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.

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
The simplest solution I have is to check which action is invoked and depending on that all the validations will be done. So in this case you will not be sung custom validations.

You have to write validation methods yourself.

Making a new Form just for this seems to be a bad idea.. The functionality can be easily done in backingBean as we have some limitation which is stopping us from using JSF provided validators.
+Pie Number of slices to send: Send
Hi guys,

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.

Thanks for the suggestions
I'm all tasted up for a BLT! This tiny ad wants a monte cristo!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1416 times.
Similar Threads
Custom JSF2.0 ExceptionHandler
JSF Vs JavaScript
intermediate submit and validation of a form
using inheritance in struts
problem with struts2...
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:00:44.