Dataconversion validating xml tranual dating site
But for now, just assume that the s:textfield tag prints a input field, and the s:submit prints a submit button.We have used label property for each tag which creates label for each tag.If no value has been supplied, we add a field error for the 'Name' field with a custom error message.
Now let us look at two ways of adding validation to our Struts project.
Hence, when validation fails and Struts 2 returns input, the Struts 2 framework will redisplay the file.
Since, we used Struts 2 form tags, Struts 2 will automatically add the error messages just above the form filed.
These error messages are the ones we specified in the add Field Error method call. The first, is the form field name to which the error applies and the second, is the error message to display above that form field.
The second method of doing validation is by placing an xml file next to the action class.
Here, we will take an example of an Employee whose name and age should be captured using a simple page, and we will put these two validations to make sure that the user always enters a name and age which should be in a range between 28 and 65.