struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pingili, Madhupal" <MPing...@BBandT.com>
Subject RE: validator-rules javascript problems - SOLVED
Date Thu, 20 May 2004 16:22:14 GMT

I solved my problem by changing field's variables names to length1 and
length2
instead of fieldLength1 and fieldLength2.
This is because of the if statement in JavascriptValidatorTag.java code:
  // skip requiredif variables field, fieldIndexed, fieldTest, fieldValue
  if (varName.startsWith("field")) {
      continue;
  }

The method and portion of the code from the struts source follows:

private String createDynamicJavascript(
        ModuleConfig config,
        ValidatorResources resources,
        Locale locale,
        Form form) {

        StringBuffer results = new StringBuffer();
        .............
        .............
                Map vars = field.getVars();
                // Loop through the field's variables.
                Iterator varsIterator = vars.keySet().iterator();
                while (varsIterator.hasNext()) {
                    String varName = (String) varsIterator.next();
                    Var var = (Var) vars.get(varName);
                    String varValue = var.getValue();
                    String jsType = var.getJsType();

                    // skip requiredif variables field, fieldIndexed,
fieldTest, fieldValue
                    if (varName.startsWith("field")) {
                        continue;
                    }
        ..................
        ...................
        return results.toString();
    }

Looking at the source code solved my problem.

Reddy Pingili
                      
> -----Original Message-----
> From:	Pingili, Madhupal 
> Sent:	Friday, April 02, 2004 10:41 AM
> To:	'Struts Users Mailing List'
> Subject:	validator-rules javascript problems
> 
> 
> I am trying to get variable values defined in validation.xml as below:
> <field    property="accountNo"
>    depends="required,numCheck">
>    <arg0 key="prepareSearchPageForm.accountno.displayname"/>
>    <arg1 name="numCheck" key="${var:fieldLength1}" resource="false"/>
>    <arg2 name="numCheck" key="${var:fieldLength2}" resource="false"/>
>    <var>
>       <var-name>fieldLength1</var-name>
>       <var-value>10</var-value>
>    </var>
>    <var>
>       <var-name>fieldLength2</var-name>
>       <var-value>13</var-value>
>    </var>
> </field>
> 
> I am extracting like validateIntRange() function:
> var iMin = parseInt(oRange[x][2]("min"));
> var iMax = parseInt(oRange[x][2]("max"));
> 
> My code is:
> var iFieldLength1 = parseInt(oNumCheck[x][2]("fieldLength1"));
> var iFieldLength2 = parseInt(oNumCheck[x][2]("fieldLength2"));
> 
> I am not getting values 10 and 13.  But, if I hard code values like 
> "iFieldLength1 = 10;", then everything works fine.
> 
> Am I missing anything here? How can I get those values?
> 
> Any help is appreciated.
> 
> Reddy Pingili
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message