DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22145>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22145

page attribute in the Validation Config file

           Summary: page attribute in the Validation Config file
           Product: Struts
           Version: 1.1 Final
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Validator Framework
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


This is more of an enhancement:

We should be allowed to set the page attribute with comma-seperated pages so 
that we do not have to define the same field validation more than once in a 
form.  Something like the following:

<field property="description" depends="maxlength" page="1,2">
    <arg0 key="resource.description"/>
    <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
    <var>
        <var-name>maxlength</var-name>
        <var-value>255</var-value>
    </var>
</field>

The following could be done to do this:

CHANGE TO JavascriptValidatorTag.java

// Skip indexed fields for now until there is a good way to handle
// error messages (and the length of the list (could retrieve from scope?))
StringTokenizer st = new StringTokenizer(field.getPage(), ",");
boolean include = false;
while(st.hasMoreTokens()) {
    if(page.equals(st.nextToken())) {
        include = true;
    }
}
if(field.isIndexed() || field.getPage() != page 
   || !field.isDependency(va.getName())) {
    continue;
}

Of course, page would have to be changed to a String in both Field and 
JavascriptValidatorTag for this to work.  

An even better idea would be to add the following functionality to Field:

int[] pages = new int[] {0};
public void setPages(String pages) throws NumberFormatException {
    if(pages != null && !pages.equal("") && !pages.equals("0")) {
        StringTokenizer st = new StringTokenizer(pages, ",");
        pages = new int[st.countTokens()];
        for(int i = 0; i < pages.length; i++) {
            pages[i] = Integer.parseInt(st.nextToken());
        }
    }
}
public int[] getPages() {
    return pages;
}
public boolean containsPage(int page) {
    for(int i = 0; i < pages.length; i++) {
        if(page == pages[i]) {
            return true;
        }
    }
    return false;   
}

Then, change JavascriptValidatorTag.java to:

// Skip indexed fields for now until there is a good way to handle
// error messages (and the length of the list (could retrieve from scope?))
if(field.isIndexed() || field.getPage() != page  || !field.containsPage(page) 
   || !field.isDependency(va.getName())) {
    continue;
}

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

Reply via email to