This week's book giveaway is in the Python forum.
We're giving away four copies of Python Continuous Integration and Delivery and have Moritz Lenz on-line!
See this thread for details.
Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Validator Problem  RSS feed

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all experts,
I'm using validator , but have some problems . Validator was not run .

addemployee.jsp

<html:form action="/Add"
name="employeeForm"
type="com.wrox.EmployeeForm" >
<table width="500" border="0">
<tr>
<td><bean:message key="app.username" />:</td>
<td><html:text property="username" /></td>
<td><bean:message key="app.password" />:</td>
<td><html assword property="password" /></td>
</tr>
...



struts-config.xml

<action input="/addemployee.jsp" name="employeeForm" path="/Add" scope="request" type="com.wrox.AddEmployeeAction" validate="true">
<forward name="success" path="/EmployeeList.do" />
<forward name="error" path="/addemployee.jsp" />
</action>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
...



validation.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN" "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
<form-validation>
<formset>
<form name="employeeForm">
<field property="username"
depends="maxlength">
<arg0 key="app.username"/>
<arg1 key="${var:maxlength}"
name="maxlength"
resource="false"/>
<var>
<var-name>maxlength</var-name>
<var-value>1</var-value>
</var>
</field>
</form>
</formset>
</form-validation>


EmployeeForm.java

package com.wrox;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.*;
import org.apache.struts.validator.ValidatorForm;


public class EmployeeForm extends ValidatorForm {

protected String username;
protected String password;
...


ApplicationResources.properties

app.username=User Name
errors.maxlength={0} can not be greater than {1} characters.
...


Why can't it run Please help me , thanks very much .
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need
<msg name="maxlength" key="errors.maxlength"/>

in your validation.xml file.

Bob
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!