looks OK to me. Do the variables _firstName and _lastName get populated by
setFirstName() and setLastName()?

Other than that I'm afraid I've no idea - I'm still writing my first struts
app!

Rob


                                                                                       
                                                           
                    "Scriven,                                                          
                                                           
                    Marcos"              To:     "'[EMAIL PROTECTED]'" 
<[EMAIL PROTECTED]>                              
                    <Marcos.Scrive       cc:                                           
                                                           
                    [EMAIL PROTECTED]>            Subject:     RE: problem with <html:errors> 
tag                                                          
                                                                                       
                                                           
                    23/10/2001                                                         
                                                           
                    13:26                                                              
                                                           
                    Please respond                                                     
                                                           
                    to struts-user                                                     
                                                           
                                                                                       
                                                           
                                                                                       
                                                           




Hi Rob

Here is my validate method (from the ActionForm bean):

    public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {
        log.debug("Validating form");
        ActionErrors errors = new ActionErrors();
        if ((_firstName == null) || (_firstName.length() < 1)) {
            errors.add("firstName", new
ActionError("error.firstname.required"));
        }
        if ((_lastName == null) || (_lastName.length() < 1)) {
            errors.add("lastName", new
ActionError("error.lastname.required"));
        }

        return errors;
    }

The problem occurs regardless of whether or not I restart the web server.
Here is my entire JSP:

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<script src="date.js"></script>
<script src="strings.js"></script>
<script src="validation.js"></script>

<html:html locale="true">
<head>
<title>Add Sales Person</title>
<html:base/>
<link rel="stylesheet" href="/stylesheets/gs1.css" type="text/css">
</head>
<body bgcolor="#003399" text="#FFFFFF">



<html:form action="/sourcefiles/dealinfo/addSalesPerson" focus="firstName">

<table border="0" width="100%">

  <tr>
    <td align="right" class="text8lilac">
        First Name
    </td>
    <td align="left">
        <html:text styleClass="form2" property="firstName" size="16"
maxlength="16" onBlur="javascript:validateName(this);"/>
        <html:errors property="firstName"/>

    </td>
  </tr>

  <tr>
    <td align="right" class="text8lilac">
      Last Name
    </td>
    <td align="left">
      <html:text styleClass="form2" property="lastName" size="16"
maxlength="16" onBlur="javascript:validateName(this);"/>
      <html:errors property="lastName"/>
    </td>
  </tr>

  <tr>
    <td align="right">
      <html:submit styleClass="form1" property="submit" value="Submit"/>
    </td>
    <td align="left">
      <html:reset styleClass="form1"/>
    </td>
  </tr>

</table>

</html:form>
</body>
</html:html>

Any help gratefully received!

Marcos

> -----Original Message-----
> From: Rob Breeds [mailto:[EMAIL PROTECTED]]
> Sent: 23 October 2001 12:46
> To: [EMAIL PROTECTED]
> Subject: RE: problem with <html:errors> tag
>
>
> you still get error messages even without the <html:errors/>
> tag? Sounds
> like a restart web app required?
>
> in the ActionForm validation() method, how do you populate Errors?
>
> Rob
>
>
>
>
>
>
>
>
>                     "Scriven,
>
>
>                     Marcos"              To:
> "'[EMAIL PROTECTED]'"
> <[EMAIL PROTECTED]>
>                     <Marcos.Scrive       cc:
>
>
>                     [EMAIL PROTECTED]>            Subject:     RE:
> problem with <html:errors> tag
>
>
>
>
>                     23/10/2001
>
>
>                     12:18
>
>
>                     Please respond
>
>
>                     to struts-user
>
>
>
>
>
>
>
>
>
>
>
>
> Thanks - but that's exactly what I did!
>
> I have two text boxes, firstName and lastName
>
> I triple checked the property names and capitalisation, and I
> still get all
> the errors.
>
> Also, I would have thought that not including any error tag
> would mean no
> errors would be displayed.
>
> Marcos
>
> > -----Original Message-----
> > From: Rob Breeds [mailto:[EMAIL PROTECTED]]
> > Sent: 23 October 2001 12:07
> > To: [EMAIL PROTECTED]
> > Subject: Re: problem with <html:errors> tag
> >
> >
> > 1. You need to put the <html:errors property="whatever"/>
> > where you want
> > them to appear. If you have several input fields, put a <html:errors
> > property="whatever"/> next to each input field.
> >
> > The header and footer are for formatting but they are optional.
> >
> > Rob Breeds
> >
> >
> >
> >
> >
> >
> >
> >
> >                     "Scriven,
> >
> >
> >                     Marcos"              To:
> > "'[EMAIL PROTECTED]'"
> > <[EMAIL PROTECTED]>
> >                     <Marcos.Scrive       cc:
> >
> >
> >                     [EMAIL PROTECTED]>            Subject:     problem
> > with <html:errors> tag
> >
> >
> >
> >
> >                     23/10/2001
> >
> >
> >                     11:48
> >
> >
> >                     Please respond
> >
> >
> >                     to struts-user
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > When I get errors with my form validation, I cannot seem to
> place them
> > where
> > I want them.
> >
> > I have tried <html:errors /> and <html:errors property="firstName"/>
> >
> > 1) In both cases (and even when there is no errors tag at
> > all), I get all
> > of
> > the errors at the top of my page... any ideas why?
> >
> > 2) Once I get errors, I then have a page with no javascript
> on it - in
> > which
> > case the user can then just type garbage, which I want to
> check on the
> > client side. How do I get around this one?
> >
> > I've seen posts that use the errors.header/footer to include
> > some clever
> > javascript - is this the only way?
> >
> > Thanks
> >
> > Marcos
> >
> >
> >
>
>
>



Reply via email to