struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <>
Subject Re: RequiredString Validation doesn't work and AbstractValidationActionSupport is missing?
Date Mon, 25 May 2009 20:56:50 GMT
Niklas Johansson wrote:
> I want to use Requieredstring validator. The problem is that my
> application is not complaining if I do leave the input field empty.

Are you using the default interceptor stack?

> Can anyone tell me what is the problem?

I don't see anything immediately obvious, but I'm sleepy.

> Q: "why you're using ParameterAware" ... "it's generally cleaner to
> just use the action properties"
> A: The reason is because I found the instructions on the struts
> homepage. Using the action properties, I assume I need to define those
> in the struts.xml, correct?

Define what in the struts.xml? The "struts homepage" doesn't have 
instructions for doing *anything*, so you'll have to be more specific as 
to what you were reading so we can correct it.

The probable answer to your question is "no". One of the main features 
(IMO) of S2 is that it eliminates a lot of back-and-forth between HTML 
forms and actions, meaning your code could be written follows, getters 
and setters elided. (And why make the action properties public if you 
have getters/setters for them?)

public class RegisterQAFormAction extends ActionSupport {

     private String message;
     private String heading;

     public String execute() throws Exception {

         // Don't know what this is trying to do, so ignoring.
         //QAHandler handleQA = new QAHandler();

         setMessage("Ă„rende " + heading + " registrerat");
         if (getHeading() == null) {
             return ERROR;

         return SUCCESS;


Note that heading won't be null if the user doesn't enter a value--it 
will be an empty string, so in all probability this is a bug in your code.

> Q: "That class is part of the showcase app, not part of Struts itself."
> A: So what is the solution? The instructions wasn't that clear about
> where the class came from on the instruction page:

Solution to what problem? You don't need that class to use the 
validation as you've written it above.


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

View raw message