I'm putting together a very basic, sample application for some training
purposes using Struts 1.1b2.  In testing the app, I cannot seem to get an
error message from an ActionForm to display on the jsp.  Can someone see
what the heck I'm doing wrong?

struts-config.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd";>

<struts-config>

        <form-beans>
                <form-bean name="LogonBean"
type="com.labone.LogonBean" />
        </form-beans>
        
        <action-mappings>
                <action path="/LogonAction"
type="com.labone.LogonAction"
                                name="LogonBean"
                                input="/logon.jsp"
                                scope="request"
                                validate="true">
                        <forward name="OK"      path="/display.jsp" />
                        <forward name="NOK"     path="/logon.jsp" />
                </action>
        </action-mappings>
        
        <message-resources
parameter="com.labone.Messages.ApplicationResources" />
        
</struts-config>

LogonBean.java

package com.labone;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

public class LogonBean extends ActionForm
{
        private String userID;
        
        public LogonBean()
        {
                this.userID = "";
        }
        
        public String getUserID()
        {
                return this.userID;
        }
        
        public void setUserID(String userID)
        {
                this.userID = userID;
        }
        
        public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request)
        {
                ActionErrors errors = new ActionErrors();
                
                if ((!userID.equals ("Jerry")) && (!userID.equals ("Qing")))
                {
                        errors.add(ActionErrors.GLOBAL_ERROR, new
ActionError("userID", "error.bad.userid"));
                }

                return errors;
        }
}

ApplicationResources.properties

errors.header=
errors.footer=

error.bad.userid = Unknown User ID!!!!

logon.jsp

<%@ taglib uri="/bean"          prefix="bean"           %>
<%@ taglib uri="/display"       prefix="display"        %>
<%@ taglib uri="/html"          prefix="html"           %>
<%@ taglib uri="/logic"         prefix="logic"          %>
<%@ taglib uri="/nested"        prefix="nested" %>
<%@ taglib uri="/tiles"         prefix="tiles"          %>

<html>
        <head>
                <title>This is a test web application</title>
        </head>
        <body>
                <table border=0>
                        <html:form action="LogonAction.do" method="POST">
                        <tr>
                                <td>
                                        User ID:
                                </td>
                                <td>
                                        <html:text maxlength="10"
property="userID" size="10" />
                                </td>
                                <td>
                                        <html:errors name="userID"/>
                                </td>
                        </tr>
                        <tr>
                                <td colspan=3>
                                        <html:submit/>
                                </td>
                        </tr>
                        </html:form>
                </table>
        </body>
</html>


Aughhhhhhhhhh!

        

Jerry Jalenak
Web Publishing
LabOne, Inc.
10101 Renner Blvd.
Lenexa, KS  66219
(913) 577-1496
[EMAIL PROTECTED]


This transmission (and any information attached to it) may be confidential and is 
intended solely for the use of the individual or entity to which it is addressed. If 
you are not the intended recipient or the person responsible for delivering the 
transmission to the intended recipient, be advised that you have received this 
transmission in error and that any use, dissemination, forwarding, printing, or 
copying of this information is strictly prohibited. If you have received this 
transmission in error, please immediately notify LabOne at (800)388-4675.



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to