struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niklas Johansson <>
Subject RequiredString Validation doesn't work and AbstractValidationActionSupport is missing‏
Date Mon, 25 May 2009 17:24:02 GMT

I am trying to create my first validation. I have two problems:

First one:

I want to use Requieredstring validator. The problem is that my
application is not complaining if I do leave the input field empty.

Here is my code:


<%@ page language="java" contentType="text/html; charset=UTF-8"
    <%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../resources/css/mobiletrainingstyle.css"
type="text/css" media="screen">
<title>Insert title here</title>

<h3 class="redtext"><s:property value="message" /></h3>

	<s:form method="POST" action="postRegisterQAForm.action">			
    		<s:textfield name="heading" label="Fråga" required="true"/>
    		<s:textarea name="answer" label="Svar" cols="30" rows="15"
       		<s:submit value="Spara" align="center"/>

 struts.xml (part of):

<package name=""
     	<action name="postRegisterQAForm"
     			<result name="input">/jsp/forms/registerqa.jsp</result>
	      		<result name="error">/jsp/forms/registerqa.jsp</result>

RegisterQAForm class:


import java.util.Map;
import org.apache.struts2.interceptor.ParameterAware;
import com.opensymphony.xwork2.ActionSupport;

public class RegisterQAFormAction extends ActionSupport implements
ParameterAware  {

    public String message;
    public String heading;

    Map param;

    public String execute() throws Exception {

        QAHandler handleQA = new QAHandler();

        setMessage("Ärende " + param.get("heading")[0] + "
        if (getHeading() != null){
              return SUCCESS;
              return ERROR;

    public void setParameters(Map param) {
        this.param = param;


    public void setMessage(String message){
         this.message = message;

    public String getMessage() {
         return message;

    public void setHeading(String heading){
        this.heading = heading;

    public String getHeading(){
        return this.heading;


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC
      "-//OpenSymphony Group//XWork Validator 1.0.2//EN"


  <field name="heading">
    <field-validator type="requiredstring">
      <param name="trim">true</param>
      <message>Heading Name is required</message>


I did put the RegisterQAForm-validation.xml in the same package as the
class RegisterQAForm. Also tried to put it in the root/default
package, no difference.

Can anyone tell me what is the problem?

Since I moved this mail-conversation from another mail that corrupted
the mail, I include some questions from the old conversation here
posted by Dave:

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?

My second problem:

I also want to use the Field Validator at some point. But it's some
problem with the AbstractValidationActionSupport class. It isn't
found. Anyone knows where this class is located? Couldn't find it in
XWork where I though it's supposed to be.

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:

Thank you in advance!


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

View raw message