You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Henry Lu <zh...@umich.edu> on 2002/02/04 13:30:20 UTC

error display

WHen there is error in the validate() function, my jsp page only displays
<ul>
</ul><hr>
Why? How to let the page display the message specified in the validate()
function?


---------------------------------------------------------------------------
Henry Lu
MCIT                                            phone: (734) 936-2063
University of Michigan Medical Center           fax:   (734) 763-4372



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


Re: error display

Posted by Pavel Nejedly <bi...@atrey.karlin.mff.cuni.cz>.
On Tue, Feb 05, 2002 at 01:03:18PM -0500, Henry Lu wrote:
# Here is my ApplicationResource.properties file used ...../classes
# directory
# 
# errors.header=<ul>
# errors.footer=</ul><hr>
# errors.id.required=id is required.
# ---------------------------------------------------------------------------
# Here is my validate() function
# 
#       if (id == null || id.equals("123") == false) {
#          errors.add(ActionErrors.GLOBAL_ERROR,
#                 new ActionError("error.id.required", "id=123"));
#       }
# ---------------------------------------------------------------------------

  you have mis-spelled the error key - in ApplicationResource.properties
  you have 'errors', but in the form only 'error'.

  Btw. I suggest you put the error message inside <li></li>, so that 
   1) you have correct html
   2) if there were more errors, the would have their own lines in the
      list

  Pavel

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


Re: error display

Posted by Henry Lu <zh...@umich.edu>.
Here is my ApplicationResource.properties file used ...../classes
directory

errors.header=<ul>
errors.footer=</ul><hr>
errors.id.required=id is required.
---------------------------------------------------------------------------
Here is my validate() function

      if (id == null || id.equals("123") == false) {
         errors.add(ActionErrors.GLOBAL_ERROR,
                new ActionError("error.id.required", "id=123"));
      }
---------------------------------------------------------------------------
Here is my jsp file

<h1>Hello, STRUTS! Enter ID:</h1>
<hr>
<html:errors />

<html:form action="/saveIdForm">
---------------------------------------------------------------------------

Did I miss something?

Thanks,


---------------------------------------------------------------------------
Henry Lu
MCIT                                            phone: (734) 936-2063
University of Michigan Medical Center           fax:   (734) 763-4372

On Tue, 5 Feb 2002, Pavel Nejedly wrote:

> On Tue, Feb 05, 2002 at 12:30:25PM -0500, Henry Lu wrote:
> # Here is my code:
> #           errors.add(ActionErrors.GLOBAL_ERROR,
> #                 new ActionError("error.id.required", "id=123"));
>
>   then you have to provide message for the key "error.id.required".
>   check the content of the file you specified as application parameter
>   of the ActionServlet.
>   eg. if you have
>
>   <servlet>
>       <servlet-name>action</servlet-name>
>       <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
>         <init-param>
>           <param-name>application</param-name>
>           <param-value>my.Msg</param-value>
>
>   then the properties file should be one of WEB-INF/classes/my/Msg.properties,
>   WEB-INF/classes/my/Msg_xx.properties or WEB-INF/classes/my/Msg_xx_YY.properties
>   where xx_YY is the current locale
>
>   the appropriate properties file should contain
>
>   error.id.required=You must supply a valid id.
>
>   or something like this.
>
>   Does it help?
>
> # Could you send me part of your code?
>
>   it looks the same... :)
>
>   Pavel
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


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


Re: error display

Posted by Pavel Nejedly <bi...@atrey.karlin.mff.cuni.cz>.
On Tue, Feb 05, 2002 at 12:30:25PM -0500, Henry Lu wrote:
# Here is my code:
#           errors.add(ActionErrors.GLOBAL_ERROR,
#                 new ActionError("error.id.required", "id=123"));

  then you have to provide message for the key "error.id.required".
  check the content of the file you specified as application parameter
  of the ActionServlet.
  eg. if you have 
  
  <servlet>
      <servlet-name>action</servlet-name>
      <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>application</param-name>
          <param-value>my.Msg</param-value>

  then the properties file should be one of WEB-INF/classes/my/Msg.properties,
  WEB-INF/classes/my/Msg_xx.properties or WEB-INF/classes/my/Msg_xx_YY.properties
  where xx_YY is the current locale

  the appropriate properties file should contain

  error.id.required=You must supply a valid id.

  or something like this.

  Does it help?
  
# Could you send me part of your code?

  it looks the same... :)

  Pavel

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


Re: error display

Posted by Henry Lu <zh...@umich.edu>.
Here is my code:
          errors.add(ActionErrors.GLOBAL_ERROR,
                new ActionError("error.id.required", "id=123"));

Could you send me part of your code?

Thanks,


---------------------------------------------------------------------------
Henry Lu
MCIT                                            phone: (734) 936-2063
University of Michigan Medical Center           fax:   (734) 763-4372

On Tue, 5 Feb 2002, Pavel Nejedly wrote:

> On Tue, Feb 05, 2002 at 12:12:40PM -0500, Henry Lu wrote:
> # I did. I include
> #
> # <html:errors/>
> #
> # in a jsp file. But when validate() function finds error, the jsp page
> # displays something like:
> #
> # <ul>
> # </ul><hr>
> #
> # on the screen.
> #
> # Why?
>
>   Have you provided the messages for all the keys inserted into
>   ActionErrors? I experienced the same behavior when I forgot to
>   include them.
>
>   Pavel
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


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


Re: error display

Posted by Pavel Nejedly <bi...@atrey.karlin.mff.cuni.cz>.
On Tue, Feb 05, 2002 at 12:12:40PM -0500, Henry Lu wrote:
# I did. I include
# 
# <html:errors/>
# 
# in a jsp file. But when validate() function finds error, the jsp page
# displays something like:
# 
# <ul>
# </ul><hr>
# 
# on the screen.
# 
# Why?

  Have you provided the messages for all the keys inserted into 
  ActionErrors? I experienced the same behavior when I forgot to 
  include them.

  Pavel

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


RE: error display

Posted by Henry Lu <zh...@umich.edu>.
I did. I include

<html:errors/>

in a jsp file. But when validate() function finds error, the jsp page
displays something like:

<ul>
</ul><hr>

on the screen.

Why?


---------------------------------------------------------------------------
Henry Lu
MCIT                                            phone: (734) 936-2063
University of Michigan Medical Center           fax:   (734) 763-4372

On Tue, 5 Feb 2002, Robert Scaduto wrote:

> You need to use the <html:errors> tag.  This will display all of the errors
> that you returned from the validate function of your action form.
>
>
>
> -----Original Message-----
> From: Henry Lu [mailto:zhlu@umich.edu]
> Sent: Monday, February 04, 2002 7:30 AM
> To: Struts Users Mailing List
> Subject: error display
>
>
> WHen there is error in the validate() function, my jsp page only displays
> <ul>
> </ul><hr>
> Why? How to let the page display the message specified in the validate()
> function?
>
>
> ---------------------------------------------------------------------------
> Henry Lu
> MCIT                                            phone: (734) 936-2063
> University of Michigan Medical Center           fax:   (734) 763-4372
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


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


RE: error display

Posted by Robert Scaduto <rs...@douwantit.com>.
You need to use the <html:errors> tag.  This will display all of the errors
that you returned from the validate function of your action form.



-----Original Message-----
From: Henry Lu [mailto:zhlu@umich.edu]
Sent: Monday, February 04, 2002 7:30 AM
To: Struts Users Mailing List
Subject: error display


WHen there is error in the validate() function, my jsp page only displays
<ul>
</ul><hr>
Why? How to let the page display the message specified in the validate()
function?


---------------------------------------------------------------------------
Henry Lu
MCIT                                            phone: (734) 936-2063
University of Michigan Medical Center           fax:   (734) 763-4372



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


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