You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by log2akshat <ak...@iiitmk.ac.in> on 2011/07/04 02:18:28 UTC

On applying action-validation.xml action is not executing.

When I am removing the validation xml file the action is executing properly
and injecting the data in the database & start sending mails, but when I am
using action-validation.xml the action is not able to execute and probably
what should be the reason for it?

--
View this message in context: http://struts.1045723.n5.nabble.com/On-applying-action-validation-xml-action-is-not-executing-tp4548473p4548473.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


RE: [struts-user] Re: On applying action-validation.xml action is not executing.

Posted by Jason Pyeron <jp...@pdinc.us>.
?

> -----Original Message-----
> From: log2akshat [mailto:akshat-pg8@iiitmk.ac.in] 
> Sent: Sunday, July 03, 2011 20:47
> To: user@struts.apache.org
> Subject: [struts-user] Re: On applying action-validation.xml 
> action is not executing.
> 
> No, validation is not failing as you can see the screenshot 

Screenshot?

> in my previous post in an another problem. The problem is 

What post?

> that when I am including the validation xml file the form is 
> validating and displaying the errors but on submitting the 
> form the method of the action class is not executing and 
> displaying only the blank page with header but on removing 
> the validation file the action class is executing and 
> injecting data in the database.
> 
> --
> View this message in context: 
> http://struts.1045723.n5.nabble.com/On-applying-action-validat
ion-xml-action-is-not-executing-tp4548473p4548510.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
> 


--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-                                                               -
- Jason Pyeron                      PD Inc. http://www.pdinc.us -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is copyright PD Inc, subject to license 20080407P00.

 


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


Re: On applying action-validation.xml action is not executing.

Posted by Dave Newton <da...@gmail.com>.
On Sun, Jul 3, 2011 at 9:11 PM, log2akshat wrote:
> 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>

Why are you doing this? What's wrong with the default stack, or an
application-specific default stack? This strikes me as error-prone and
unnecessary.

> <validators>
>    <field name="appform.Name">

Why are you using non-standard property names?

>            <message key="validate_Name"/>

And key names?

> My SubmitAppFormAction class:

You have *far* too much logic encapsulated in your action. *Far* too
much. Refactor.

> package net.Candidate.application.action;

And a non-standard package name?

> import java.sql.*;

Um...

> import javax.naming.*;

Why?

> import javax.mail.internet.*;
> import com.sun.mail.smtp.*;
> import com.sun.mail.smtp.SMTPSSLTransport.*;
> import javax.activation.*;

They have third-party libraries to make sending emails a lot easier, you know.

Not that you should be sending an email in action code anyway.

>                        System.out.println("JDBC MySQL Connection....");

Use logging.

>                                code removed just for security

And sanity. But it shouldn't be there anyway.

Just out of curiosity, how many lines long is the "add()" method?

> 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.

Are you doing JavaScript validation? Ajax validation? How are you
showing the error messages? What theme are you using? Are you using
the Spring plugin? Have you done any form validation successfully in
the application, or did you write all this then start debugging
everything at once?

Dave

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


Re: On applying action-validation.xml action is not executing.

Posted by Jeff Black <je...@yahoo.com>.
I'm with Dave: I think you should try using the "defaultStack" or at a minimum 
the "validationWorkflowStack" of Interceptors to begin eliminating a possible 
misconfiguration.

It's probably nothing, but I thought I would mention it -- Did you double-check 
your Tiles configuration?

jb
/



________________________________
From: log2akshat <ak...@iiitmk.ac.in>
To: user@struts.apache.org
Sent: Sun, July 3, 2011 8:11:46 PM
Subject: Re: On applying action-validation.xml action is not executing.

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">

<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

Re: On applying action-validation.xml action is not executing.

Posted by log2akshat <ak...@iiitmk.ac.in>.
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


Re: On applying action-validation.xml action is not executing.

Posted by Dave Newton <da...@gmail.com>.
I'm supposed to remember a previous post, for a different problem, realize
they're related, on my cell phone? Right, okay, I'll let someone else jump
through those hoops.

Post complete questions, with code or config: why would you make it
difficult for people to help you?

It's difficult to guess what you're doing.

Dave
 On Jul 3, 2011 8:47 PM, "log2akshat" <ak...@iiitmk.ac.in> wrote:
> No, validation is not failing as you can see the screenshot in my previous
> post in an another problem. The problem is that when I am including the
> validation xml file the form is validating and displaying the errors but
on
> submitting the form the method of the action class is not executing and
> displaying only the blank page with header but on removing the validation
> file the action class is executing and injecting data in the database.
>
> --
> View this message in context:
http://struts.1045723.n5.nabble.com/On-applying-action-validation-xml-action-is-not-executing-tp4548473p4548510.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
>

Re: On applying action-validation.xml action is not executing.

Posted by log2akshat <ak...@iiitmk.ac.in>.
No, validation is not failing as you can see the screenshot in my previous
post in an another problem. The problem is that when I am including the
validation xml file the form is validating and displaying the errors but on
submitting the form the method of the action class is not executing and
displaying only the blank page with header but on removing the validation
file the action class is executing and injecting data in the database.

--
View this message in context: http://struts.1045723.n5.nabble.com/On-applying-action-validation-xml-action-is-not-executing-tp4548473p4548510.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


Re: On applying action-validation.xml action is not executing.

Posted by Dave Newton <da...@gmail.com>.
Validation is failing? Bad validation file? Type conversion failure? You
didn't really give us much to go on.

Dave
On Jul 3, 2011 8:18 PM, "log2akshat" <ak...@iiitmk.ac.in> wrote:
> When I am removing the validation xml file the action is executing
properly
> and injecting the data in the database & start sending mails, but when I
am
> using action-validation.xml the action is not able to execute and probably
> what should be the reason for it?
>
> --
> View this message in context:
http://struts.1045723.n5.nabble.com/On-applying-action-validation-xml-action-is-not-executing-tp4548473p4548473.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
>