Hi everyone,
I have setup a simple application to freshen up my memories of
Struts 2. I think I have done whatever was needed to enjoy client side validation for user input data. The fact is it seems I've missed something. I searched, browsed, thought, etc... but still no luck
First of all, a
jsp (displayClient.jsp) with a form:
in the same jsp, in the head section I added the <s:head/> as instructed by various tutorials :
so my action name is "saveClient". Let's have a look at struts.xml:
so this action is supposed to call clientAction.save() and forward to:
success: listeClient.jsp (displaying clients)
input: The jsp at action's start
error: a jsp set to display errors & warnings
so in the package com.mysoft.lab.view there are 2 files:
clientAction.java
clientAction-validation.xml
clientAction.java defines a class extending com.opensymphony.xwork2.ActionSupport with appropriate setters and getters plus the action methods.
the clientAction-validation.xml contains:
the values such as errors.range are defined in a file called clientAction.properties :
So all the fields are supposed to be required. I checked the HTML generated by tomat, the form validation calls a javascript function aimed at the input validation and the follwing line has been added by
tomcat in the <head> section:
So I guess everything's fine. Except that whatever input I put in the fields (valid or not), the action is completed and a new record is added to the database. I know I should also check for validation on server side as you can never trust a client side validation but the goal here is to demonstrate client side validation...
I am pretty sure I'll be banging my head on a wall when the light will be shed on my issue but I would really appreciate if someone could point me to what I missed here for I am clueless.
Thanks a million
Franck