I am having a problem with my ActionForm validate() method returning a blank
jsp page.
It is a very simple logon.jsp with only two required fields "username" and
"Password" The ActionForm validates that the user has in fact entered
something in both fields. If the user has left a field blank, the ActionForm
should return an error, "please enter a username", etc. All validation after
that is performed in the logonAction execute() such as "user not found in
system", "invalid username, password" etc. The LogonAction execute() returns
errors to the logon.jsp as it should. My logonForm however, does not, just a
blank (empty) jsp page. Any suggestions would be greatly appreciated.

Here is my JSP

<%@ page contentType="text/html;charset=iso-8859-1" language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<html:form action="/Logon" name="logonForm"
type="biz.books.logon.LogonForm">
<BODY bgcolor="#FFFFFF" leftMargin=0 topMargin=0 marginwidth="0"
marginheight="0" class=bg>
<table width="750" border="0">
  <tr>
    <td width="169"><html:errors/></td>
    <td width="524">&nbsp;</td>
    <td width="43">&nbsp;</td>
  </tr>
  <tr>
    <td><div align="right" class="style2">username:</div></td>
    <td><html:text property="username" size="30"/> </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align="right" class="style2">password:</div></td>
    <td><html:password property="password" size="30"/> </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><html:submit/></td>
    <td>&nbsp;</td>
  </tr>
</table>
</BODY>
</html:form> 

My STRUTS-CONFIG

<form-bean name="logonForm"
           type="biz.books.logon.LogonForm">
</form-bean>

<action path="/Logon" 
           type="biz.books.logon.LogonAction" 
           name="logonForm"
           scope="request" 
           validate="true" 
           input="/logon.jsp">
              <forward name="fail" path="/logon.jsp" />
              <forward name="success" path="/userhome.page" />
        </action>

My ActionForm

/**
 * Form bean for the user signon page.
 */
public class LogonForm extends ActionForm {

  private String password;
  private String username;
  
  public LogonForm(){
        password = "";
        username = "";
  }
  
//getters and setters are here

public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request)
{
     ActionErrors errors = new ActionErrors();

      if ((username == null) || (username.length() < 1))
          errors.add("username", new ActionError("error.noUsername"));
          
      if ((password == null) || (password.length() < 1))
          errors.add("password", new ActionError("error.noPassword"));
         

      return errors;
}
 

Thanks in advance!  
-Lynne

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

Reply via email to