struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aniruddha <>
Subject Visitor field validation with dynamic context
Date Fri, 01 Jun 2007 07:26:41 GMT

I am using struts2 for my application. 

While validating a User say in User-validation.xml, I want to use the
visitor field validation in the following way.

    <field name="companyInformation">
        <field-validator type="visitor">
            &lt;param name="appendPrefix">true&lt;/param>
            &lt;param name="context">someContext&lt;/param>

In the snippet above is there a way to define the someContext dynamically
(from my Action class)????

If you want more detail of a use case similar to mine i have created an
example below. 

Suppose i have a class called User which has a field called inHouseUser and
a field called companyInformation of type CompanyInformation. If the user is
not an inhouse user only then i wish to validate certail fields of the
companyInformation, not otherwise.

I have created the class called User as:

public class User {
        private boolean inHouseUser;
        private CompanyInformation companyInformation;

        public CompanyInformation getCompanyInformation() {
                return companyInformation;

        public void setCompanyInformation(CompanyInformation
companyInformation) {
                this.companyInformation = companyInformation;

        public boolean isInHouseUser() {
                return inHouseUser;

        public void setInHouseUser(boolean inHouseUser) {
                this.inHouseUser = inHouseUser;

In the validation snippet is there a way to define the someContext
dynamically, say by using the prepare method based on the value of the field
inHouseUser. Let us assume that i have only one method in my action class
(execute) which is used irrespective of the User being an inHouse User or an
external User.

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message