I am new to struts2 and I am confused as to which validation framework to be used.
I have a page where I show number of users in the tabular form like.
FIRST NAME1, LAST NAME1 , EMAIL1
FIRST NAME2, LAST NAME2 , EMAIL2
each one of which could be modified and saved, the save works in one go and updates all the records or creates new. I do not have any issue with the data save or display.
I am using
struts library to display it on the page.
<s:iterator value="contacts" status="stat">
<tr>
<td><s:textfield name="contacts[%{#stat.index}].firstName" label="FIRST NAME" /></td>
<td><s:textfield name="contacts[%{#stat.index}].lastName" label="LAST NAME" /></td>
<td><s:textfield name="contacts[%{#stat.index}].email" label="email" /></td>
</tr>
<tr> .... </tr> <!-- one row for every record -->
<tr> .... </tr>
</s:iterator>
I am setting the contacts collection in the action class as below.
private List<Contact> contacts
Please assume the usual getter and setters.
I want to validate that the email id that is entered is valid email, or for that matter phone number entered for every individual user is numeric.
It seems to me that I won't be able to use the field validation in this case rather than I will have to use the generic validation. Although I will prefer the first one.
Please advise.