I changed the architecture of the validation framework
over the weekend.  I made a class call
ValidatorResourcesInitializer that will create a
ValidatorResources based on a file name or an
InputStream.  I'm not sure how different your rules
would be for each user.  If it is completely
different, you could have a file for each user and
load it into session scope when they logon.  If it is
mainly the same with exceptions, you could have an xml
file dynamically generated with a JSP page filling in
the changes per user.  These exceptions to the general
validation could be stored in a database or even
another XML file.

This is a code snippet from ValidatorForm. 
ValidatorUtil.getValidatorResources() gets the
ValidatorResources from application scope, but you
could get it from session scope or get an InputStream
from a URL.  

ServletContext application =
getServlet().getServletContext();

// Load from a file or even from a dynamic page (jsp)
ValidatorResources resources = 
ValidatorResourcesInitializer.initialize(InputStream
of a JSP/XML page or file name);

//ValidatorResources resources =  
//   
ValidatorUtil.getValidatorResources(application);
Locale locale = ValidatorUtil.getLocale(request);
ActionErrors errors = new ActionErrors();
Validator validator = new Validator(resources, 
            mapping.getAttribute());

These are ideas off the top of my head.  If each user
or group is possibly an exception to the general form
rules, I can see that dynamically generating the xml
might be tedious.  If that is what you are doing, let
me know.  In the meantime I'll think about what would
be involved having a user/group attribute for form,
field, msg, arg0-arg3, and var.  Icould work similiar
to retrieving a locale resource.  First look for a
user value, then a group, and then the default value.

<field    property="stateProv">
   <arg0
key="registrationForm.stateprov.displayname"/>
</field>
<field    property="stateProv" user="Joe">
   <arg0
key="registrationForm.stateprov.displayname"/>
</field>

Validator validator = new Validator(resources, 
            mapping.getAttribute());
validator.setUser("Joe");

Comments?  Is anyone else doing anything like this or
planning on doing anything like this?

David
http://home.earthlink.net/~dwinterfeldt


--- [EMAIL PROTECTED] wrote:
> Hi David,
> 
> Sorry to brother u, I post this message few days ago
> in struts mailing list,
> no one reply yet 8(.  I would like to have your
> advice about how I can setup
> an environment for ASP model which use Struts and
> Validators.  For example,
> if different subscribers can have different
> requirement regarding
> validations, how should I setup the validator.xml.
> Or do I have to setup the
> web.xml to access different validator.xml for
> different subscriber?
> 
> Thanks in advance 8)
> 
> Chris
> 
> ================
> Previous Posting
> ================
> 
> I would like to know anyone using Struts and
> Validators for ASP (application
> service provider, not active server page 8)) model. 
> What I want to know is
> If I have the same application for different
> subscribers/clients, they may
> have different requirements (e.g. screen flow and
> validation, etc.).  Which
> implies each subscriber may has its own
> struts-config.xml / validator.xml.
> My question is what is the best deployment strategy
> for that?
> 
> Any ideas?
> 
> Thanks in advance!
> 
> Chris


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to