struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From log2akshat <akshat-...@iiitmk.ac.in>
Subject Re: On applying action-validation.xml action is not executing.
Date Mon, 04 Jul 2011 01:11:46 GMT
Sorry for the confusion....

Actually, I have a form that needs to be validated and on successful
validation it should populate the data in the database as well as able to
send the mails to the mail IDs provided in the form. All the functionality
is working fine as long as I am not validating my form but as soon as I
start using the validation script through action-validation.xml file the
form starts validating but on submission of the form it is not populating
the database and sending the mails only it is redirecting to the success
page where it is only showing the errors and I am not getting any errors
also.

Action name is : Submitappform
The name of the action class is : SubmitAppFormAction
Validation file name : SubmitAppFormAction-validation.xml

My *struts.xml* file for this action:
<action name="Submitappform"
class="net.Candidate.application.action.SubmitAppFormAction" method="add">
	<interceptor-ref name="params">dojo\..*,^struts\..*</interceptor-ref>
	<interceptor-ref
name="validation">input,back,cancel,browse</interceptor-ref>
	<interceptor-ref name="workflow">input,back,cancel,browse</interceptor-ref>
<result name="input" type="tiles">OLAppForm</result>
<result name="error" type="tiles">OLAppForm</result>
<result name="success" type="tiles">AppFormSubmitSuccess</result>
</action>

My SubmitAppFormAction-validation.xml file is:

<?xml version="1.0" encoding="UTF-8" ?>
&lt;!DOCTYPE validators PUBLIC &quot;-//OpenSymphony Group//XWork Validator
1.0.2//EN&quot; 
&quot;http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd&quot;&gt;

<validators>
    <field name="appform.Name">
        <field-validator type="requiredstring">
        true
            <message key="validate_Name"/>
        </field-validator>
    </field>
    
    <field name="appform.Surname">
        <field-validator type="requiredstring">
        true
            <message key="validate_Surname"/>
        </field-validator>
    </field>
    
    <field name="appform.DOB">
        <field-validator type="requiredstring">
        true
            <message key="validate_DOB"/>
        </field-validator>
    </field>
    
    <field name="appform.Gender">
        <field-validator type="required">
        true
            <message key="validate_Gender"/>
        </field-validator>
    </field>
    
    <field name="appform.Nationality">
        <field-validator type="requiredstring">
        true
            <message key="validate_Nationality"/>
        </field-validator>
    </field>
    
    <field name="appform.CAddress">
        <field-validator type="requiredstring">
        true
            <message key="validate_CAddress"/>
        </field-validator>
    </field>
    
    <field name="appform.CPin">
        <field-validator type="requiredstring">
        true
            <message key="validate_CPin"/>
        </field-validator>
    </field>
    
    <field name="appform.CCity">
        <field-validator type="required">
        true
            <message key="validate_CCity"/>
        </field-validator>
    </field>
    
    <field name="appform.CState">
        <field-validator type="required">
        true
            <message key="validate_CState"/>
        </field-validator>
    </field>
    
    <field name="appform.Telephone">
        <field-validator type="requiredstring">
        true
            <message key="validate_Telephone"/>
        </field-validator>
    </field>
    
    <field name="appform.PAddress">
        <field-validator type="requiredstring">
        true
            <message key="validate_PAddress"/>
        </field-validator>
    </field>
    
    <field name="appform.PPin">
        <field-validator type="requiredstring">
        true
            <message key="validate_PPin"/>
        </field-validator>
    </field>
    
    <field name="appform.PCity">
        <field-validator type="required">
        true
            <message key="validate_PCity"/>
        </field-validator>
    </field>
    
    <field name="appform.PState">
        <field-validator type="required">
        true
            <message key="validate_PState"/>
        </field-validator>
    </field>
   
   <field name="appform.Category">
        <field-validator type="requiredstring">
        true
            <message key="validate_Category"/>
        </field-validator>
    </field>
    
	<field name="appform.Referee1Email">
        <field-validator type="requiredstring" short-circuit="true">
        true
            <message key="validate_Referee1Email"/>
        </field-validator>
        <field-validator type="email">
			<message key="validate_RefereeEmail"/>
		</field-validator>
    </field>
    
</validators>

My SubmitAppFormAction class:

package net.Candidate.application.action;

import java.io.*;
import java.sql.*;
import java.util.*;

import javax.naming.*;
import javax.mail.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.mail.internet.*;
import com.sun.mail.smtp.*;
import com.sun.mail.smtp.SMTPSSLTransport.*;
import javax.activation.*;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ActionContext;

import net.database.*;
import net.Candidate.application.model.Apply;
import net.Candidate.application.model.Appform;
import net.Candidate.Registration.controller.SendMailBean;

public class SubmitAppFormAction extends ActionSupport {
	
	private Appform appform;
	private SendMailBean sendMail;
	
	public SubmitAppFormAction() {
		sendMail = new SendMailBean();
	}
	
	public String add() {
		try 
		{
			Connection connect = null;
			ResultSet result = null;
			PreparedStatement pstmt = null;
			
			DBConnection getConnect = new DBConnection();
			connect = getConnect.getCon();
			System.out.println("JDBC MySQL Connection....");
			
				String query = "INSERT INTO applicant VALUES(NULL,?,?,?,?)";
				pstmt = connect.prepareStatement(query);
				pstmt.setString(1, appform.getName());
				pstmt.setString(2, appform.getSurname());
				pstmt.setString(3, appform.getDOB());
				pstmt.setString(4, appform.getGender());
	      =======Similar code deleted just for security============
				pstmt.executeUpdate();
				
				int OnlineID = 0;
				ResultSet result_ID = null;
			
				String IDqry = "Select OnlineID from applicant where Email=?";
				pstmt = connect.prepareStatement(IDqry);
				pstmt.setString(1, appform.getEmail());
				result_ID = pstmt.executeQuery();
				{
				        while (result_ID.next())
				        {
				            OnlineID = result_ID.getInt(1);    
				        }
				 }
				
			
								
////////////////////////////////////////////////////Mail Sending
Mechanism/////////////////////////////////////////////////////
				
				code removed just for security
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
		
	
	public Appform getAppform() {
		return appform;
	}	
	public void setAppform(Appform appform) {
		this.appform = appform;
	}
	

	public SendMailBean getSendMailBean() {
		return sendMail;
	}	
	public void setSendMailBean(SendMailBean sendMail) {
		this.sendMail = sendMail;
	}
}

==========================================================

The other problem which I am facing is that in my validation half of the
validation is working fine but in the half form old error message is not
clearing, and the new error message is showing in a new line. On clicking
again the previous error messages are there and the new message is adding in
a new row.

I am attaching the Screenshot of the Error Messages.
http://struts.1045723.n5.nabble.com/file/n4548549/Screenshot.png 

--
View this message in context: http://struts.1045723.n5.nabble.com/On-applying-action-validation-xml-action-is-not-executing-tp4548473p4548549.html
Sent from the Struts - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message