File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Passing a string array in var-value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Passing a string array in var-value" Watch "Passing a string array in var-value" New topic

Passing a string array in var-value

Hentay Duke
Ranch Hand

Joined: Oct 27, 2004
Posts: 198
I've tried google but can't seem to find anything on this.

Is it possible to pass a string array in <var-value>. For example something like this (though this doesn't work).

I want to check if any of the fields I'm passing is filled in. And if so they must all be filled in. I can do seperate checks on each one but then I get mutliple(redundant) error messages, so I'd like to pass the array and loop through it in my validator-rules.xml, therefore only having one standard error message if any of them fail.

Hope this makes sense.

Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
In general, if I have validation that is slightly complex I just implement the validate method and write it in Java. Be sure to call super.validate.

The validator framework actually calls get methods on your ActionForm, correct? Maybe you could add a getMailingFields method to your form that returns an empty string if any of the fields are empty and then create a validation rule on mailingFields.

If you are using Dynamic forms, then this may not apply.

- Brent
I agree. Here's the link:
subject: Passing a string array in var-value
It's not a secret anymore!