dgraham 2003/08/23 10:18:39
Modified: src/share/org/apache/struts/validator/validwhen
ValidWhen.java
Log:
Replaced deprecated Resources.getActionError() calls.
Revision Changes Path
1.7 +30 -14
jakarta-struts/src/share/org/apache/struts/validator/validwhen/ValidWhen.java
Index: ValidWhen.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/validator/validwhen/ValidWhen.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ValidWhen.java 4 Jul 2003 20:38:19 -0000 1.6
+++ ValidWhen.java 23 Aug 2003 17:18:39 -0000 1.7
@@ -91,14 +91,21 @@
* Checks if the field matches the boolean expression specified in
* <code>test</code> parameter.
*
- [EMAIL PROTECTED] bean The bean validation is being performed on.
- [EMAIL PROTECTED] va The <code>ValidatorAction</code> that is currently
being performed.
- [EMAIL PROTECTED] field The <code>Field</code> object associated with the
current
+ * @param bean The bean validation is being performed on.
+ *
+ * @param va The <code>ValidatorAction</code> that is currently being
+ * performed.
+ *
+ * @param field The <code>Field</code> object associated with the current
* field being validated.
- [EMAIL PROTECTED] errors The <code>ActionErrors</code> object to add errors
to if any
+ *
+ * @param errors The <code>ActionErrors</code> object to add errors to if any
* validation errors occur.
- [EMAIL PROTECTED] request Current request object.
- [EMAIL PROTECTED] True if meets stated requirements, False otherwise
+ *
+ * @param request Current request object.
+ *
+ * @return <code>true</code> if meets stated requirements,
+ * <code>false</code> otherwise.
*/
public static boolean validateValidWhen(
Object bean,
@@ -116,10 +123,12 @@
if (field.isIndexed()) {
String key = field.getKey();
- if ((key.indexOf("[") > -1) && (key.indexOf("]") > -1)) {
+ final int leftBracket = key.indexOf("[");
+ final int rightBracket = key.indexOf("]");
+
+ if ((leftBracket > -1) && (rightBracket > -1)) {
index =
- Integer.parseInt(
- key.substring(key.indexOf("[") + 1, key.indexOf("]")));
+ Integer.parseInt(key.substring(leftBracket + 1, rightBracket));
}
}
@@ -148,12 +157,19 @@
} catch (Exception ex) {
ex.printStackTrace();
- errors.add(field.getKey(), Resources.getActionError(request, va,
field));
+
+ errors.add(
+ field.getKey(),
+ Resources.getActionMessage(request, va, field));
+
return false;
}
if (!valid) {
- errors.add(field.getKey(), Resources.getActionError(request, va,
field));
+ errors.add(
+ field.getKey(),
+ Resources.getActionMessage(request, va, field));
+
return false;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]