I'll preface this by saying that i am extremely new at using
struts. Finally got around the various error and display issues and now i'm just not getting anything. when i submit the form i get a blank page (/testing.do), i was under the impression that it would return to the page indicated in the input parameter of the action-mapping. The following is the code that i'm using, any input would be appreciated.
***************************************************
struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="infoForm" type="com.x.struts.InfoForm"/>
</form-beans>
<action-mappings>
<action path="/testing"
type="com.x.struts.InfoAction"
name="infoForm"
scope="request"
validate="true"
input="/Submit1.jsp">
</action>
</action-mappings>
<message-resources parameter="/WEB-INF/eng_messages.properties"/>
</struts-config>
********************************************************************
Submit1.jsp
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-form.tld" prefix="form" %>
<html>
<head>
<title>Struts Number One Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<%@ page language="java"%>
<body>
<html:errors/>
<html:form action="/testing.do" focus="FirstName">
<table width="500" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>First Name:</td>
<td><html:text property="firstName"/></td>
</tr>
<tr>
<td>Last Name:</td>
<td><html:text property="lastName"/></td>
</tr>
<tr>
<td>Address:</td>
<td><html:text property="address"/></td>
</tr>
<tr>
<td>Address 2:</td>
<td><html:text property="address2"/></td>
</tr>
<tr>
<td>City:</td>
<td><html:text property="city"/></td>
</tr>
<tr>
<td>Province/State:</td>
<td><html:text property="provState"/></td>
</tr>
<tr>
<td>Country:</td>
<td><html:text property="country"/></td>
</tr>
<tr>
<td>Postal/Zip:</td>
<td><html:text property="postalZip"/></td>
</tr>
<tr>
<td>Phone:</td>
<td><html:text property="phone"/></td>
</tr>
<tr>
<td>Email:</td>
<td><html:text property="email"/></td>
</tr>
<tr>
<td colspan="2"><html:submit value="submit"/></td>
</tr>
</table>
</html:form>
</body>
</html>
***************************************************************
validate method of the com.x.struts.InfoForm bean
public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping, javax.servlet.ServletRequest request) {
int confirm = 0;
com.x.validation.Validate validate = new com.x.validation.Validate();
org.apache.struts.action.ActionErrors messages = new org.apache.struts.action.ActionErrors();
if(request.getParameter("FirstName").trim().length() == 0){
confirm += 1;
messages.add(messages.GLOBAL_MESSAGE, new org.apache.struts.action.ActionMessage("validate.FirstName.incomplete"));
}
if(request.getParameter("LastName").trim().length() == 0){
confirm += 1;
messages.add(messages.GLOBAL_MESSAGE, new org.apache.struts.action.ActionMessage("validate.LastName.incomplete"));
}
if(request.getParameter("Address").trim().length() == 0){
confirm += 1;
messages.add(messages.GLOBAL_MESSAGE, new org.apache.struts.action.ActionMessage("validate.Address.incomplete"));
}
if(request.getParameter("Phone").trim().length() == 0){
confirm += 1;
messages.add(messages.GLOBAL_MESSAGE, new org.apache.struts.action.ActionMessage("validate.Phone.incomplete"));
}
if(!validate.email(request.getParameter("Email"))){
confirm += 1;
messages.add(messages.GLOBAL_MESSAGE, new org.apache.struts.action.ActionMessage("validate.Email.incomplete"));
}
if(confirm > 0){
return messages;
} else {
return null;
}
}
*********************************************************************
eng_messages.properties file
validate.FirstName.incomplete=<LI>Please input your first name.</LI>
validate.LastName.incomplete=<LI>Please input your last name.</LI>
validate.Address.incomplete=<LI>Please input your Address.</LI>
validate.Phone.incomplete=<LI>Please input your Phone.</LI>
validate.Email.incomplete=<LI>Please input a valid email address.</LI>
*******************************************************************
thanks for your help