You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Robert Taylor <rt...@mulework.com> on 2002/09/18 17:00:40 UTC

[Validator] problem accessing field args

I've implemented Dave Winterfeldts comparing two fields
example and want to simply display the message,

'Confirm Password' and 'New Password' do not match.

when the fields are not equal.


What I'm getting is
'Confirm Password' and null do not match.



This is a snippet of my validation.xml:

<field property="newPassword" depends="required,minlength,maxlength">
  <arg0 key="form.account.newPassword.displayName"/>
  <arg1 name="minlength" key="${var:minlength}" resource="false"/>
  <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
  <var>
     <var-name>minlength</var-name>
     <var-value>6</var-value>
  </var>
  <var>
     <var-name>maxlength</var-name>
     <var-value>12</var-value>
  </var>
</field>

<field property="confirmPassword"
       depends="required,minlength,maxlength,compare">
  <arg0 key="form.account.confirmPassword.displayName"/>
  <arg1 name="secondProperty" key="form.account.newPassword.displayName"/>
  <arg1 name="minlength" key="${var:minlength}" resource="false"/>
  <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
  <var>
    <var-name>minlength</var-name>
    <var-value>6</var-value>
  </var>
  <var>
    <var-name>maxlength</var-name>
    <var-value>12</var-value>
  </var>
  <var>
    <var-name>secondProperty</var-name>
    <var-value>newPassword</var-value>
  </var>
</field>

I have the following in my ApplicationResources.properties file:
errors.compare={0} and {1} do not match.

form.account.currentPassword.displayName='Current Password'
form.account.newPassword.displayName='New Password'
form.account.confirmPassword.displayName='Confirm Password'



This is a snippet from my validator-rules.xml file:

<validator name="compare"
  classname="com.newatlanta.applications.web.BasicValidator"
  method="compareTwoFields"
  methodParams="java.lang.Object,
  org.apache.commons.validator.ValidatorAction,
  org.apache.commons.validator.Field,
  org.apache.struts.action.ActionErrors,
  javax.servlet.http.HttpServletRequest"
  msg="errors.compare">
</validator>

I looked into the source code and found that the
StrutsValidatorUtil.getArgs() was responsible for retrieving the arguments
from the field for the ActionError message. I put in  some debug statements
and found that it was not "seeing" the other arguments.


arg0: Arg: name=null  key=form.account.confirmPassword.displayName
resource=true
arg1: null
arg2: null
arg3: null


So, I'm stumped. I've spent the last 4 hours on this and am convinced it
must be a simple configuration issue or something I'm missing. I was hoping
a fresh mind might be able to guide me to a solution.

TIA,

robert


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>