Custom validation method that returns multiple error messages

2003-04-03 Thread Moore, Scott R.
Hi all,

I'm using a custom validation method to enforce three rules regarding
passwords.  I would like to be able to display up to three error messages,
but at first glance, the format required for the validator tag in my
custom-validator-rules.xml file only permits one error message:

  !-- Validator for ensuring a password does not contain all or part of
user name --
  validator name=enforceSecurePassword
   classname=gov.sec.lib.validation.Validation
   method=enforceSecurePassword
   methodParams=java.lang.Object,
 org.apache.commons.validator.ValidatorAction,
 org.apache.commons.validator.Field,
 org.apache.struts.action.ActionErrors,
 javax.servlet.http.HttpServletRequest,
 javax.servlet.ServletContext   
   msg=errors.password/
   
Anybody know if there is a way around this?  Or do I have to have separate
custom validation methods to enforce each rule?

Thanks,
Scott Moore
[EMAIL PROTECTED]

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



RE: Netscape 4.7 disable fields

2003-04-01 Thread Moore, Scott R.

Potential workaround to keep those 3 ns4 users happy (actually i think
there's more like 7):

- Clicking the button sets a Javascript variable disableTextBoxes to true
- The textboxes have an onchange function that:
- if disableTextBoxes is false, it stores the textbox value in an array
- if disableTextBoxes is true, it changes the textbox value back to the
previous value saved in the array

So when disableTextBoxes is true, the user could edit the field value, but
as soon as the focus leaves that field it will change back to its orig
value--it's in effect uneditable.

A nice extra touch would be to have an onfocus handler in the textboxes that
calls a function tellUserIfDisabled().  tellUserIfDisabled() checks
disableTextBoxes, and if it is true, shows them an alert saying that they
shouldn't change the value in that textbox.

It's a total hack but having had to work with NS 4.7 before I got used to
doing such things...  ugh.

HTH,
Scott.

-Original Message-
From: Mark Lowe [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 01, 2003 12:06 PM
To: Struts Users Mailing List
Subject: Re: Netscape 4.7  disable fields


A couple of years back i had to get disabled form element behaviour 
working on ns4 and used dynamically gnerated and positioned divs with a 
tranparent image to cover the elements ... But i think its very silly 
and a waste of time.

It quite a lot of dhtml fiddlyness for all 3 ns4 users.. :)

Lunedì, 31 mar 2003, alle 18:19 Europe/Rome, James Mitchell ha scritto:

 On Mon, 2003-03-31 at 11:12, Gus Delgado wrote:
 Has anyone run with his/her Struts application and Nestcape 4.7. I 
 have
 a few textfields that once a button is click the text field go from
 being enable to disable (read-only) it works great on IE 5.5 and
 Netscape 6.0 but it seems that Netscape 4.7 does not understand the
 disable=true attribute.  Any ideas?

 Netscape 4.x does not support disabled fields.
 If you must support that browser version, use html:hidden with the 
 write
 option:
  http://jakarta.apache.org/struts/userGuide/struts-html.html#hidden


 Thanks
 Gus


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 -- 
 James Mitchell
 Software Developer/Struts Evangelist
 http://www.open-tools.org




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



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

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



RE: question regarding DynaActionForm.reset()

2003-03-31 Thread Moore, Scott R.
Hi,

Two questions related to this issue: 

1) Does this mean that the following statement in Chuck Cavanaugh's
Programming Jakarta Struts (O'Reilly) is wrong?:

Unlike with the ActionForm Class, where the default behavior for reset()
does nothing, the reset() method in the DynaActionForm class resets all the
properties back to their initial values.

2) Does DynaValidatorForm.reset() also do nothing?  According to the
Javadoc, it should Reset all properties to their default values, however,
when I run the following code snippet in my Action class (the variable
form is the ActionForm object that is given to the method):

DynaValidatorForm dynaForm = (DynaValidatorForm) form;
String firstNameBefore = (String) dynaForm.get(firstName);
// SRM debug:
System.out.println(initRequestForm(): resetting form values.);

dynaForm.reset(mapping, request);

String firstNameAfter = (String) dynaForm.get(firstName);

// SRM debug:
System.out.println(Value before reset:  + firstNameBefore);
System.out.println(Value after reset:  + firstNameAfter);

it prints out identical values for firstNameBefore and firstNameAfter, even
if I have set a default value using the initial attribute in
struts-config.xml.

Thanks,
Scott Moore
[EMAIL PROTECTED]

-Original Message-
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]
Sent: Monday, March 31, 2003 2:52 PM
To: Struts Users Mailing List
Subject: Re: question regarding DynaActionForm.reset()


On Mon, 31 Mar 2003, Donald Ball wrote:

 Date: Mon, 31 Mar 2003 13:39:33 -0500
 From: Donald Ball [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: question regarding DynaActionForm.reset()

 The API for ActionForm.reset() says it will, Reset all bean properties
 to their default state. This method is called before the properties are
 repopulated by the controller servlet. Why then does the default
 reset() method for DynaActionForm do nothing? DynaActionForm knows about
 its own dynamic properties, it would be easy enough to clear() the map.

 Note I'm not complaining, the resulting behavior is actually what I
 think I want to have happen, I'm just trying to figure out why it's
 designed this way...?


Originally, the reset() method actually did mess with the map, but this
behavior was inconsistent with the do-nothing behavior of reset() in the
standard ActionForm class.  The bug report related to this was:

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

As a result, we removed the previous behavior of reset(), in version 1.7
of DynaActionForm just before 1.1-beta3 was released.

 - donald


Craig

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

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



RE: question regarding DynaActionForm.reset()

2003-03-31 Thread Moore, Scott R.

A coworker pointed out a workaround for explicitly resetting a
DynaValidatorForm in my Action class, so I thought I'd share it.  In the
Action class that handles an ActionForm (which is really a DynaValidatorForm
configured in struts-config.xml):

  // form is the ActionForm object passed in to the method
  DynaValidatorForm dynaForm = (DynaValidatorForm) form;
  dynaForm.getMap().clear();

This is helpful in situations like mine, where:
 - The user enters some data in a form, then gets some errors reported by
the Validator framework.
 - The user is shown a form with error messages, and each form field is
pre-populated with data they just submitted so they can quickly correct
their errors
 - The user goes elsewhere in your web app, then returns to the form
mentioned above, and you do NOT want to pre-populate the form fields with
the data they entered before.

HTH.  Thanks Wendy and Donald for your replies earlier.

--Scott
[EMAIL PROTECTED]





-Original Message-
From: Wendy Smoak [mailto:[EMAIL PROTECTED]
Sent: Monday, March 31, 2003 3:45 PM
To: 'Struts Users Mailing List'
Subject: RE: question regarding DynaActionForm.reset()


Scott wrote:
 2) Does DynaValidatorForm.reset() also do nothing?  According to the
 Javadoc, it should Reset all properties to their default values,
however,
 when I run the following code snippet in my Action class (the variable
 form is the ActionForm object that is given to the method):

Anecdotally, yes, DynaValidatorForm.reset() does nothing.  
You have to implement it in your own form if you want it to do something.

   public void reset( ActionMapping mapping, HttpServletRequest request )
   {
  initialize(mapping);
   }

It's documented on DynaValidatorForm's parent, DynaActionForm:
http://jakarta.apache.org/struts/api/org/apache/struts/action/DynaActionForm
.html

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management

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