This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Struts and the fly likes Validator Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validator Problem" Watch "Validator Problem" New topic

Validator Problem

Vu Pham
Ranch Hand

Joined: May 28, 2005
Posts: 100
Hi all experts,
I'm using validator , but have some problems . Validator was not run .


<html:form action="/Add"
type="com.wrox.EmployeeForm" >
<table width="500" border="0">
<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>


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


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN" "">
<form name="employeeForm">
<field property="username"
<arg0 key="app.username"/>
<arg1 key="${var:maxlength}"

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;

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 .
Bob Harrison

Joined: Apr 18, 2006
Posts: 12
I think you need
<msg name="maxlength" key="errors.maxlength"/>

in your validation.xml file.


"In theory there is no difference between theory and practice. In practice there is."<br />Yogi Berra
I agree. Here's the link:
subject: Validator Problem
jQuery in Action, 3rd edition