You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kurt McCaw <ku...@hotmail.com> on 2001/09/05 08:58:17 UTC

Newbie question - Sometimes Data Validation ?

Hello:

I have a simple scenario that I need help with. While a user is adding or 
editing information on a data entry screen (it is the same ActionForm and 
Action) - to click a button to save the information as the defaults for any
subsequent new data entry screen. This saving of the default values would be 
done without running the data validation code. Yet I would like to make sure 
that when the user hits the 'Submit' or 'Save' button - the system does the 
appropriate data validation before saving the information away.

My question is how do I do this with Struts? I am trying to use the 'Wintec' 
validation routines (but I think this would be the same problem if I was 
using them or not) - but I am not sure how to do 'sometimes data validation' 
on a data entry screen. I started off with a button on the screen:
<html:submit>
  <bean:message key="button.setDefault"/>
</html:submit>
but I could not get this to work. I could not get the button to do anything 
other than trying to submit the information (but that is probably another 
issue).

Since I could not get the 'button' to work - I was then trying to use a 
link:
<html:link SomeForm.do?action=setDefault/>. This would at least call the 
'peform()' method with the correct action, but I had to turn off the 
validation in 'struts-config.xml'.

Any help or suggestions would get greatly appreciated.

Regards,
Kurt


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


Re: Newbie question - Sometimes Data Validation ?

Posted by Ted Husted <hu...@apache.org>.
The ValidatorForm tags include a switch for skipping validation. It is
usually used for CANCEL buttons, but should also work for what you are
trying to do here. 

    <html:submit onclick="bCancel=true;">
      <bean:message key="button.saveDefaults"/>
    </html:submit>

In your Action, you should be able to check to see which button they
pressed, to do whatever else needs to be done.


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/about/struts/


Kurt McCaw wrote:
> 
> Hello:
> 
> I have a simple scenario that I need help with. While a user is adding or
> editing information on a data entry screen (it is the same ActionForm and
> Action) - to click a button to save the information as the defaults for any
> subsequent new data entry screen. This saving of the default values would be
> done without running the data validation code. Yet I would like to make sure
> that when the user hits the 'Submit' or 'Save' button - the system does the
> appropriate data validation before saving the information away.
> 
> My question is how do I do this with Struts? I am trying to use the 'Wintec'
> validation routines (but I think this would be the same problem if I was
> using them or not) - but I am not sure how to do 'sometimes data validation'
> on a data entry screen. I started off with a button on the screen:
> <html:submit>
>   <bean:message key="button.setDefault"/>
> </html:submit>
> but I could not get this to work. I could not get the button to do anything
> other than trying to submit the information (but that is probably another
> issue).
> 
> Since I could not get the 'button' to work - I was then trying to use a
> link:
> <html:link SomeForm.do?action=setDefault/>. This would at least call the
> 'peform()' method with the correct action, but I had to turn off the
> validation in 'struts-config.xml'.
> 
> Any help or suggestions would get greatly appreciated.
> 
> Regards,
> Kurt