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 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 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.
OK I guess I know. This is not a Struts issue but rather a maven one.
Out of curiosity I looked at the deployed war. Horror there wasn't any *****-validation.xml file in the com.mysoft.lab.view class directory. I manually added these two files and reloaded the war in Tomcat.
it works !
so I have now to figure out how to tell maven I need to keep xml files along with class files....
I guess I gonna open another thread in the maven section.