Return-Path: X-Original-To: apmail-struts-commits-archive@minotaur.apache.org Delivered-To: apmail-struts-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 411D5D0F1 for ; Thu, 11 Oct 2012 19:33:37 +0000 (UTC) Received: (qmail 48548 invoked by uid 500); 11 Oct 2012 19:33:37 -0000 Delivered-To: apmail-struts-commits-archive@struts.apache.org Received: (qmail 48525 invoked by uid 500); 11 Oct 2012 19:33:37 -0000 Mailing-List: contact commits-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list commits@struts.apache.org Received: (qmail 48518 invoked by uid 99); 11 Oct 2012 19:33:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Oct 2012 19:33:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Oct 2012 19:33:34 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 78F8723889BB for ; Thu, 11 Oct 2012 19:32:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1397252 - /struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidator.java Date: Thu, 11 Oct 2012 19:32:48 -0000 To: commits@struts.apache.org From: lukaszlenart@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121011193248.78F8723889BB@eris.apache.org> Author: lukaszlenart Date: Thu Oct 11 19:32:48 2012 New Revision: 1397252 URL: http://svn.apache.org/viewvc?rev=1397252&view=rev Log: WW-3888 updates documentation regarding expression evaluation Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidator.java Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidator.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidator.java?rev=1397252&r1=1397251&r2=1397252&view=diff ============================================================================== --- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidator.java (original) +++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidator.java Thu Oct 11 19:32:48 2012 @@ -15,7 +15,6 @@ */ package com.opensymphony.xwork2.validator.validators; - /** * * Field Validator that checks if the integer specified is within a certain range. @@ -28,34 +27,49 @@ package com.opensymphony.xwork2.validato *
  • min - the minimum value (if none is specified, it will not be checked)
  • *
  • max - the maximum value (if none is specified, it will not be checked)
  • * + * + * The min / max value can be specified as an expression, but then you must also enable parsing it by specifying parse param + * as in the example below. + * WARNING! Do not use ${min} and ${max} as an expression as this will turn into infinitive loop! + * * * * *
      * 
    - * 		<validators>
    - *           <!-- Plain Validator Syntax -->
    - *           <validator type="int">
    - *               <param name="fieldName">age</param>
    - *               <param name="min">20</param>
    - *               <param name="max">50</param>
    - *               <message>Age needs to be between ${min} and ${max}</message>
    - *           </validator>
    - *           
    - *           <!-- Field Validator Syntax -->
    - *           <field name="age">
    - *               <field-validator type="int">
    - *                   <param name="min">20</param>
    - *                   <param name="max">50</param>
    - *                   <message>Age needs to be between ${min} and ${max}</message>
    - *               </field-validator>
    - *           </field>
    - *      </validators>
    + *	<validators>
    + *      <!-- Plain Validator Syntax -->
    + *      <validator type="int">
    + *          <param name="fieldName">age</param>
    + *          <param name="min">20</param>
    + *          <param name="max">50</param>
    + *          <message>Age needs to be between ${min} and ${max}</message>
    + *      </validator>
    + *
    + *      <!-- Field Validator Syntax -->
    + *      <field name="age">
    + *          <field-validator type="int">
    + *              <param name="min">20</param>
    + *              <param name="max">50</param>
    + *              <message>Age needs to be between ${min} and ${max}</message>
    + *          </field-validator>
    + *      </field>
    + *
    + *      <!-- Field Validator Syntax with expression -->
    + *      <field name="age">
    + *          <field-validator type="int">
    + *              <param name="parse">true</param>
    + *              <param name="${minValue}">20</param> <!-- will be evaluated as: Integer getMinValue() -->
    + *              <param name="${maxValue}">50</param> <!-- will be evaluated as: Integer getMaxValue() -->
    + *              <message>Age needs to be between ${min} and ${max}</message>
    + *          </field-validator>
    + *      </field>
    + * </validators>
      * 
      * 
    * - * - * + * + * * @author Jason Carreira * @version $Date$ $Id$ */