• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

headache with validation framework

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!!!

Check the following:

1. You have given the form name in the attribute <arg> as "ExcursionForm" whereas the form name is "excursionForm". Change "E" to "e" in <arg>

2. Check if you made an entry in your properties file for excursionForm.description

Hope this will rectify your problem
[ May 30, 2005: Message edited by: bhuvan sundar ]
 
Natalia Lopez
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I did that but Still not work.
Anyway Thank you, I resolve the problem using method validate in each Form class

Naty
 
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic