Hi!!!
I'm using
struts 1.1 with tiles and validator but te problem is that i can validate anything, The
jsp files don't make any validation. I follow the struts-validation.war example that you can find in the struts home page.
I did a litle guide of what you need to configure in your proyect to use strut validator, anyway seems I'm forgeting something because nothing work.
- Web.xml
put debug in 2
put detail in 2
If exist any <param-name>application......... delete
-Strut-config.xml
Add to the end for example
<message-resources parameter="resource.excursion"/>
Where excursion is a properties files with something like
#errors
error.header=</H3..................
errors.required={0} es un capo requerido.
errors.integer={0} must be an integer.
errors.double={0} must be an double.
errors.price={0} must be an double.
error.excurcion.description.required=<LI>Ingrese Descripci�n</LI>
-Validation.xml
<form-validation>
<form name="excursionForm">
<field property="description"
depends=required">
<arg key="ExcursionForm.description"/>
</field>
-......Form.java
Public final clase ....Form extends ValidatorForm implements Serializable
-......Action.java
nothing especial
-.........jsp
Whell I still can't understand the diferentin using javascript in server and client or validation over the client.
This is the jsp that I'm using now
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html>
<HEAD>
<title><bean:message key="excursionForm.title"/></title>
<html:base/>
</head>
<BODY>
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font color="#0000FF">New</font></td>
</tr>
<tr>
<td>
<!--<html:errors />-->
<logic:messagesPresent>
<bean:message key="errors.header"/>
<ul>
<html:messages id="error">
<li><bean:write name="error"/></li>
</html:messages>
</ul><hr>
</logic:messagesPresent>
<html:form action="/NewExcursionAction" onsubmit="return validateExcursionForm(this);">
<html:hidden property="action"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td width="7%">Descripci�n:</td>
<td width="5%"><html:text property="description" /></td>
<td width="6%"> </td>
</tr>
<tr>
<td width="3%" nowrap> </td>
<td nowrap>Duraci�n:</td>
<td nowrap><html:text property="duration"/></td>
<td nowrap> </td>
</tr>
<tr>
<td nowrap> </td>
<td nowrap>Hs de salida:</td>
<td nowrap><html:text property="departureTime"/></td>
<td nowrap> </td>
</tr>
<tr>
<td nowrap> </td>
<td nowrap>Precio:</td>
<td nowrap> <html:text property="price"/></td>
<td nowrap> </td>
</tr>
<tr>
<td nowrap> </td>
<td nowrap>Capacidad Total:</td>
<td nowrap><html:text property="totalCapacity"/></td>
<td nowrap> </td>
<td nowrap> </td>
</tr>
<tr>
<td nowrap> </td>
<td nowrap>
<html:submit property="submit">
<bean:message key="button.save"/>
</html:submit>
<html:cancel>
<bean:message key="button.cancel"/>
</html:cancel>
</td>
<td nowrap> </td>
</tr>
<tr>
<td nowrap> </td>
<td nowrap> </td>
<td nowrap> </td>
<td nowrap> </td>
</tr>
</table>
</html:form>
<!-- Begin Validator Javascript Function
<validator:javascript formName="excursionForm"/>
<!-- End of Validator Javascript Function-->
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</BODY>
</body>
</html:html>
Any help guide tutorial or book is welcome.
First I try to add Javascript validation code by my self but struts tags seems not support javascript in the traditional way and I can't finde the way for validations.
Regards
Naty