Re: Validation Question how to echo back users input in error message?

2005-11-08 Thread Niall Pemberton
The short answer is that there isn't a way to echo back user input in the
error message. Most of the time I don't think its necessary to do so
anyway - since if you're re-displaying/highlighting errors then what is the
need. The one time I scenario I wanted to do something like that, was when I
had a list, say for example you are displaying a list of orders and you want
a message along the lines Order date for order number 1234 is invalid -
where the order number 1234 is a value from the list.

There are two places that I know of, where this kind of functionality has
been provided. The first is in the extends validator I wrote (see the
indexed example):

   http://www.niallp.pwp.blueyonder.co.uk/strutsvalidatorextends.html

...and the other place was in the javascript validator extension I started
work on:

   http://www.niallp.pwp.blueyonder.co.uk/validatorjs.html

Hopefully, one day I will find some time to work on validator to make these
kind of features standard - but for now theres nothing out of the box to
meet this requirement.

Niall

- Original Message - 
From: Michael Jouravlev [EMAIL PROTECTED]
Sent: Friday, November 04, 2005 6:01 PM


I would like to know the answer on this too. I searched the Net, all
examples use properties from property file. Using resource=false
does not help with either (neither?) of these variants:

arg0 key=nestedUser.fromAddress resource=false/
arg0 key=${nestedUser.fromAddress} resource=false/
arg0 key=registrationForm.nestedUser.fromAddress resource=false/
arg0 key=${registrationForm.nestedUser.fromAddress} resource=false/

where registrationForm is action form definition in struts-config.xml,
nestedUser is a nested BO. Originating mail address is rendered in
HTML and submitted back to application as nestedUser.fromAddress.

Commons Validator does not process HttpServletRequest (that is
expected). I glanced at ValidatorForm from Struts Validator
integration, and saw this validate() method:

public ActionErrors validate(ActionMapping mapping,
 HttpServletRequest request) {

  ServletContext application = getServlet().getServletContext();
  ActionErrors errors = new ActionErrors();

  String validationKey = getValidationKey(mapping, request);

  Validator validator = Resources.initValidator(validationKey,
this, application, request, errors, page);

  try {
validatorResults = validator.validate();
  } catch (ValidatorException e) {
log.error(e.getMessage(), e);
  }

  return errors;
}

So, maybe you want to debug this one.

Commons Validator basically does not have documentation, only
Javadocs, which is not very descriptive. No comments in the source,
either. This is frustrating.

Michael.

On 11/4/05, Troy Bull [EMAIL PROTECTED] wrote:
 I am using the struts validator and it works almost exactly the way I
want.


 Say I have a field tf and the value is ABC

 I want to do a validation requiring it to be an integer and return the
 following error message: tf must be an integer.

 I can do all this pretty easily here is the code that does it:

 in ApplicationResources.properties :

 validation.error.acty.integer={0} must be an integer and {1} is not.

 in validations.xml

   field property=acty depends=integer
 msg name=integer key=validation.error.acty.integer/
 arg0 key=ACTY resource=false/
 arg1 key=${??} resource=false/
   /field


 my question is what do I put in ?? to get hte actual value the user
 entered to be echoed back out

 so if I type in AAA into the acty field I want the error message to be:

 ACTY must be an integer and AAA is not.

 Thanks Troy



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Validation Question how to echo back users input in error message?

2005-11-04 Thread Troy Bull

I am using the struts validator and it works almost exactly the way I want.


Say I have a field tf and the value is ABC

I want to do a validation requiring it to be an integer and return the 
following error message: tf must be an integer.


I can do all this pretty easily here is the code that does it:

in ApplicationResources.properties :

validation.error.acty.integer={0} must be an integer and {1} is not.

in validations.xml

 field property=acty depends=integer
   msg name=integer key=validation.error.acty.integer/
   arg0 key=ACTY resource=false/
   arg1 key=${??} resource=false/
 /field


my question is what do I put in ?? to get hte actual value the user 
entered to be echoed back out


so if I type in AAA into the acty field I want the error message to be:

ACTY must be an integer and AAA is not.

Thanks Troy 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Validation Question how to echo back users input in error message?

2005-11-04 Thread Michael Jouravlev
I would like to know the answer on this too. I searched the Net, all
examples use properties from property file. Using resource=false
does not help with either (neither?) of these variants:

arg0 key=nestedUser.fromAddress resource=false/
arg0 key=${nestedUser.fromAddress} resource=false/
arg0 key=registrationForm.nestedUser.fromAddress resource=false/
arg0 key=${registrationForm.nestedUser.fromAddress} resource=false/

where registrationForm is action form definition in struts-config.xml,
nestedUser is a nested BO. Originating mail address is rendered in
HTML and submitted back to application as nestedUser.fromAddress.

Commons Validator does not process HttpServletRequest (that is
expected). I glanced at ValidatorForm from Struts Validator
integration, and saw this validate() method:

public ActionErrors validate(ActionMapping mapping,
 HttpServletRequest request) {

  ServletContext application = getServlet().getServletContext();
  ActionErrors errors = new ActionErrors();

  String validationKey = getValidationKey(mapping, request);

  Validator validator = Resources.initValidator(validationKey,
this, application, request, errors, page);

  try {
validatorResults = validator.validate();
  } catch (ValidatorException e) {
log.error(e.getMessage(), e);
  }

  return errors;
}

So, maybe you want to debug this one.

Commons Validator basically does not have documentation, only
Javadocs, which is not very descriptive. No comments in the source,
either. This is frustrating.

Michael.

On 11/4/05, Troy Bull [EMAIL PROTECTED] wrote:
 I am using the struts validator and it works almost exactly the way I want.


 Say I have a field tf and the value is ABC

 I want to do a validation requiring it to be an integer and return the
 following error message: tf must be an integer.

 I can do all this pretty easily here is the code that does it:

 in ApplicationResources.properties :

 validation.error.acty.integer={0} must be an integer and {1} is not.

 in validations.xml

   field property=acty depends=integer
 msg name=integer key=validation.error.acty.integer/
 arg0 key=ACTY resource=false/
 arg1 key=${??} resource=false/
   /field


 my question is what do I put in ?? to get hte actual value the user
 entered to be echoed back out

 so if I type in AAA into the acty field I want the error message to be:

 ACTY must be an integer and AAA is not.

 Thanks Troy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]