File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Action class not being called after validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Action class not being called after validation" Watch "Action class not being called after validation" New topic

Action class not being called after validation

Manjunath Muniyappa

Joined: Feb 22, 2010
Posts: 1
Hi All,

I am new to Struts2. I am tring to run a simple application which has one JSP and one java class. My jsp has few fields where user enters data. Once they click on submit, I need to validate them and return back if there is any missing data. I am using struts2 validation i.e classname-validation.xml. What is happening is that, even though I enter all the data in the JSP and click on submit, my application still shows that data fileds are required!!!Also after clicking on submit button, my action class is not getting called. I am posting my code here below. Please help me!!!

Action class

package com.wa;
import com.opensymphony.xwork2.ActionSupport;

public class RefundsLessThanThreeThousand extends ActionSupport {

private static final long serialVersionUID = 1L;
private String AccountNumber;
private String ValueofSignOff;
private String CustomerName;
private String Address;
private String PeriodofSignOff;
private String DetailedReason;

public String getsAccountNumber() {
System.out.println("____________________________ AccountNumber "+AccountNumber);
return AccountNumber;
public void setsAccountNumber(String AccountNumber) {
this.AccountNumber = AccountNumber;
System.out.println("____________________________ AccountNumber "+AccountNumber);
public String getsValueofSignOff() {
return ValueofSignOff;

public void setsValueofSignOff(String ValueofSignOff) {
this.ValueofSignOff = ValueofSignOff;
System.out.println("____________________________ ValueofSignOff "+ValueofSignOff);
public String getsCustomerName() {
return CustomerName;
public void setsCustomerName(String CustomerName) {
this.CustomerName = CustomerName;
System.out.println("____________________________ CustomerName "+CustomerName);
public String getsAddress() {
return Address;
public void setsAddress(String Address) {
this.Address = Address;
System.out.println("____________________________ Address "+Address);
public String getsPeriodofSignOff() {
return PeriodofSignOff;
public void setsPeriodofSignOff(String PeriodofSignOff) {
this.PeriodofSignOff = PeriodofSignOff;
System.out.println("____________________________ PeriodofSignOff "+PeriodofSignOff);
public String getsDetailedReason() {
return DetailedReason;
public void setsDetailedReason(String DetailedReason) {
this.DetailedReason = DetailedReason;
System.out.println("____________________________ DetailedReason "+DetailedReason);

public String createcase(){
System.out.println("____________________________ entered the jaa class");
return "sucess";

public String execute(){
System.out.println("____________________________ entered the jaa class exe");
return "sucess";



<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat" %>


<s:form action="RefundsLessThanThreeThousand.action" method="post" name="RefundsLessThanThreeThousand" >
<s:textfield name="AccountNumber" key="label.AccountNumber" size="30" />
<s:textfield name="ValueofSignOff" key="label.ValueofSignOff" size="30"/>
<s:textfield name="CustomerName" key="label.CustomerName" size="50" />
<s:textarea name="Address" key="label.Address" rows="8" cols="30"/>
<s:textfield name="PeriodofSignOff" key="label.PeriodofSignOff" size="30"/>
<s:textarea name="DetailedReason" key="label.DetailedReason" rows="8" cols="30"/>
<s:submit method="execute" key="label.Submit" align="center" />
<s:reset key="label.clear" align="center" ></s:reset>

<?xml version="1.0" encoding="UTF-8" ?>
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

<constant name="struts.enable.DynamicMethodInvocation"
value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources"
value="ApplicationResources" />

<package name="default" extends="struts-default" namespace="/">
<action name="LoginAction"
<result name="success">/pages/Welcome/Welcome.jsp</result>
<result name="error">/pages/login/Login.jsp</result>
<action name="RefundsLessThanThreeThousand"
<result name="sucess">/pages/login/Login.jsp</result>
<result name="input">/pages/RefundsLessThanThreeThousand/RefundsLessThanThreeThousand.jsp</result>
<result ></result>



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

<field name="AccountNumber">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="errors.required" />
<field name="ValueofSignOff">
<field-validator type="required">
<message key="errors.required" />
<field-validator type="int">
<param name="min">350</param>
<param name="max">3000</param>
<message key="errors.range"/>
<field name="CustomerName">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="errors.required" />
<field name="Address">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="errors.required" />
<field name="PeriodofSignOff">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="errors.required" />
<field name="DetailedReason">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="errors.required" />

David Newton

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.

Also, when posting code samples, it's best to limit them to the minimum necessary to replicate the problem; things like System.out.println just obfuscate the actual issues.

And welcome to JavaRanch!
I agree. Here's the link:
subject: Action class not being called after validation
It's not a secret anymore!