You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Team Gasoline <te...@earthlink.net> on 2002/04/20 02:28:55 UTC

null in html on validation

Hello --

I'm having a problem  with errors being surrounded by "null" on my page 
after validation. Here is a snippet of the html when i view source of 
the page through the browser.

   <tr>
     <th align="right">
       User Name:
     </th>
     <td align="left">
       <input type="text" name="username" maxlength="16" size="16" 
value="">
       null
	<td bgcolor="gray"><font color="red" size=2><--Required 
Field</font></td>
	null

     </td>
   </tr>

Here is what I have in my jsp.

   <tr>
     <th align="right">
       <bean:message key="prompt.username"/>
     </th>
     <td align="left">
       <html:text property="username" size="16" maxlength="16"/>
       <html:errors property="username"/>
     </td>
   </tr>

and my form.

     public ActionErrors validate(ActionMapping mapping,
                                  HttpServletRequest request) {

         ActionErrors errors = new ActionErrors();
         if ((username == null) || (username.length() < 1))
             errors.add("username", new 
ActionError("error.username.required"));

         return errors;

     }

Has anyone ever seen this before. I have checked everywhere and have 
found no good answers.

Thanks.

RE: null in html on validation

Posted by srinivas <sv...@intensit.de>.
Hi,
In the action did u save errors and then forward to the jsp.

Try calling this method
saveErrors(request, errors);
and then forward.

Regards,
srinivas


-----Original Message-----
From: Team Gasoline [mailto:teamgasoline@earthlink.net] 
Sent: Saturday, April 20, 2002 3:29 AM
To: struts-user@jakarta.apache.org
Subject: null in html on validation

Hello --

I'm having a problem  with errors being surrounded by "null" on my page 
after validation. Here is a snippet of the html when i view source of 
the page through the browser.

   <tr>
     <th align="right">
       User Name:
     </th>
     <td align="left">
       <input type="text" name="username" maxlength="16" size="16" 
value="">
       null
	<td bgcolor="gray"><font color="red" size=2><--Required 
Field</font></td>
	null

     </td>
   </tr>

Here is what I have in my jsp.

   <tr>
     <th align="right">
       <bean:message key="prompt.username"/>
     </th>
     <td align="left">
       <html:text property="username" size="16" maxlength="16"/>
       <html:errors property="username"/>
     </td>
   </tr>

and my form.

     public ActionErrors validate(ActionMapping mapping,
                                  HttpServletRequest request) {

         ActionErrors errors = new ActionErrors();
         if ((username == null) || (username.length() < 1))
             errors.add("username", new 
ActionError("error.username.required"));

         return errors;

     }

Has anyone ever seen this before. I have checked everywhere and have 
found no good answers.

Thanks.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>