Ping...... Any help here...

--------------------
Mick Knutson
Wells Fargo Business Direct
(415) 222-1020

"This message may contain confidential and/or privileged information. If you 
are not the addressee or authorized to receive this for the addressee, you must 
not use, copy, disclose, or take any action based on this message or any 
information herein. If you have received this message in error, please advise 
the sender immediately by reply e-mail and delete this message. Thank you for 
your cooperation."
--------------------



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, December 10, 2004 3:42 PM
To: [EMAIL PROTECTED]
Subject: Validator upgrade?


with the new struts 1.2.4 upgrade, I started to change all the <arg0 ...> to 
<arg position="0"...> but find that my custom validators are not being found.
1. Is there a doc on upgrading the validator?
2. Anyone ever heard of this happening?

Here is  my <form> validator:
==========================
                        <field property="businessLineSelected" 
depends="isequalif">
                                <msg name="isequalif" 
key="requiredif.productSelectionRequired"/>
                                <arg position="0" 
key="form.businessLineSelected"/>
                                <var>
                                        <var-name>thisValue[0]</var-name>
                                        <var-value>true</var-value>
                                </var>
                                <var>
                                        <var-name>field[0]</var-name>
                                        
<var-value>businessCardSelected</var-value>
                                </var>
                                <var>
                                        <var-name>fieldTest[0]</var-name>
                                        <var-value>EQUAL</var-value>
                                </var>
                                <var>
                                        <var-name>fieldValue[0]</var-name>
                                        <var-value>false</var-value>
                                </var>
                                <var>
                                        <var-name>field[1]</var-name>
                                        
<var-value>businessSecuredCardSelected</var-value>
                                </var>
                                <var>
                                        <var-name>fieldTest[1]</var-name>
                                        <var-value>EQUAL</var-value>
                                </var>
                                <var>
                                        <var-name>fieldValue[1]</var-name>
                                        <var-value>false</var-value>
                                </var>
                                <var>
                                        <var-name>field[2]</var-name>
                                        
<var-value>equipmentExpressSelected</var-value>
                                </var>
                                <var>
                                        <var-name>fieldTest[2]</var-name>
                                        <var-value>EQUAL</var-value>
                                </var>
                                <var>
                                        <var-name>fieldValue[2]</var-name>
                                        <var-value>false</var-value>
                                </var>
                                <var>
                                        <var-name>fieldJoin</var-name>
                                        <var-value>AND</var-value>
                                </var>
                        </field>

And here is my custom validator:
===========================      <validator name="isequalif"
                 classname="com.wf.bd.ice.rules.validation.ICEFieldChecks"
                 method="validateIsEqualIf"
                 methodParams="java.lang.Object,
                               org.apache.commons.validator.ValidatorAction,
                               org.apache.commons.validator.Field,
                               org.apache.struts.action.ActionMessages,
                               org.apache.commons.validator.Validator,
                               javax.servlet.http.HttpServletRequest"
                 msg="isequalif.default">
      </validator>


and here is the method in our ICEFieldChecks:
===================================

    public static boolean validateIsEqualIf(
        Object bean, ValidatorAction va, Field field, ActionMessages errors,
        org.apache.commons.validator.Validator validator,
        HttpServletRequest request
    ) {
        Object form =
            validator.getResource(
                org.apache.commons.validator.Validator.BEAN_KEY
            );
        String value = null;

        if(isString(bean)) {
            value = (String) bean;
        } else {
            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
        }

        if(value == null) {
            value = "";
        }

        boolean required = false;
        java.util.Collection theseValues = new ArrayList();

        int j = 0;

        while(
            !GenericValidator.isBlankOrNull(
                    field.getVarValue("thisValue[" + j + "]")
                )
        ) {
            theseValues.add(field.getVarValue("thisValue[" + j++ + "]"));
        }

        if(theseValues.isEmpty()) {
            return true;
        }

        int i = 0;
        String fieldJoin = "AND";

        if(!GenericValidator.isBlankOrNull(field.getVarValue("fieldJoin"))) {
            fieldJoin = field.getVarValue("fieldJoin");
        }

        if(fieldJoin.equalsIgnoreCase("AND")) {
            required = true;
        }

        while(
            !GenericValidator.isBlankOrNull(
                    field.getVarValue("field[" + i + "]")
                )
        ) {
            String dependProp = field.getVarValue("field[" + i + "]");
            String dependTest = field.getVarValue("fieldTest[" + i + "]");
            String dependTestValue = field.getVarValue("fieldValue[" + i + "]");
            String dependIndexed = field.getVarValue("fieldIndexed[" + i + "]");

            if(dependIndexed == null) {
                dependIndexed = "false";
            }

            String dependVal = null;
            boolean thisRequired = false;

            if(field.isIndexed() && dependIndexed.equalsIgnoreCase("true")) {
                String key = field.getKey();

                if((key.indexOf("[") > -1) && (key.indexOf("]") > -1)) {
                    String ind = key.substring(0, key.indexOf(".") + 1);
                    dependProp = ind + dependProp;
                }
            }

            dependVal = ValidatorUtil.getValueAsString(form, dependProp);

            if(dependTest.equals(FIELD_TEST_NULL)) {
                if((dependVal != null) && (dependVal.length() > 0)) {
                    thisRequired = false;
                } else {
                    thisRequired = true;
                }
            }

            if(dependTest.equals(FIELD_TEST_NOTNULL)) {
                if((dependVal != null) && (dependVal.length() > 0)) {
                    thisRequired = true;
                } else {
                    thisRequired = false;
                }
            }

            if(dependTest.equals(FIELD_TEST_EQUAL)) {
                thisRequired = dependTestValue.equalsIgnoreCase(dependVal);
            }

            if(fieldJoin.equalsIgnoreCase("AND")) {
                required = required && thisRequired;
            } else {
                required = required || thisRequired;
            }

            i++;
        }

        if(required) {
            if(!theseValues.contains(value)) {
                errors.add(
                    field.getKey(), Resources.getActionMessage(
                        request, va, field
                    )
                );

                return false;
            } else {
                return true;
            }
        }

        return true;
    }




--------------------
Mick Knutson
Wells Fargo Business Direct Information Systems
(415) 222-1020

"This message may contain confidential and/or privileged information. If you 
are not the addressee or authorized to receive this for the addressee, you must 
not use, copy, disclose, or take any action based on this message or any 
information herein. If you have received this message in error, please advise 
the sender immediately by reply e-mail and delete this message. Thank you for 
your cooperation."
--------------------



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


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

Reply via email to