You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pete Serafin <ps...@sbti.com> on 2001/12/04 15:46:30 UTC
Error tag problem
All,
I am having a similar problem to Binh
(
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg18646.html
).
I was wondering if anyone has a solution as to why I cannot get the
<html:errors> tag to work. I did notice that Struts docs say:
"In order to use this tag successfully, you must have defined an
application scope MessageResources bean under the default attribute
name, with at least the following message keys: errors.header,
errors.footer "
Where is the MessageResources bean instantiated and what is the "default
name" mentioned?
The following is how my app is set up according to my web.xml,
ApplicationResources.properties, strtus-config.xml, and my ActionForm
and jsp:
1) ApplicationResources.properties:
errors.header=<ul>
errors.footer=</ul>
2) web.xml
...
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
...
3)struts-config.xml
<action path="/login" type="action.loginAction"
input="/login.jsp"
name="loginForm"
scope="request"
validate="true">
<forward name="success" path="/index.jsp"/>
<forward name="error" path="/login.jsp"/>
</action>
4) LoginForm.java
....
public ActionErrors validate(ActionMapping
mapping,HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ((userID == null) || (userID.length() < 1))
errors.add("login", new
ActionError("error.userID.required"));
return errors;
}
...
5) login.jsp
...
<%@ taglib uri="/WEB-INF/taglibs/struts-html.tld" prefix="html" %>
...
<html:errors/>
...
Im not getting the errors tag to print anything to the page, but the
validation is returning it to the form properly.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Error tag problem
Posted by Pete Serafin <ps...@sbti.com>.
Sean,
you are correct, my ApplicationResources file is in my /classes directory,
therefor, I just have the file name listed. Is there anything else you did to
get the error handling working?
Pete
Sean Owen wrote:
> I believe your web.xml needs to be more like this:
>
> <init-param>
> <param-name>application</param-name>
> <param-value>com.myapp.web.ApplicationResources</param-value>
> </init-param>
>
> The ApplicationResources.properties should end up in the same directory as
> the compiled .class files for com.myapp.web. I suggest you copy it there in
> your build process. Anyhow this setup works for me.
>
> Sean
>
> ----- Original Message -----
> From: "Pete Serafin" <ps...@sbti.com>
> To: <st...@jakarta.apache.org>
> Sent: Tuesday, December 04, 2001 2:46 PM
> Subject: Error tag problem
>
> > All,
> >
> > I am having a similar problem to Binh
> > (
> > http://www.mail-archive.com/struts-user@jakarta.apache.org/msg18646.html
> >
> > ).
> > I was wondering if anyone has a solution as to why I cannot get the
> > <html:errors> tag to work. I did notice that Struts docs say:
> >
> > "In order to use this tag successfully, you must have defined an
> > application scope MessageResources bean under the default attribute
> > name, with at least the following message keys: errors.header,
> > errors.footer "
> >
> > Where is the MessageResources bean instantiated and what is the "default
> >
> > name" mentioned?
> >
> > The following is how my app is set up according to my web.xml,
> > ApplicationResources.properties, strtus-config.xml, and my ActionForm
> > and jsp:
> > 1) ApplicationResources.properties:
> >
> > errors.header=<ul>
> > errors.footer=</ul>
> >
> > 2) web.xml
> > ...
> > <init-param>
> > <param-name>application</param-name>
> > <param-value>ApplicationResources</param-value>
> > </init-param>
> > ...
> >
> > 3)struts-config.xml
> >
> > <action path="/login" type="action.loginAction"
> > input="/login.jsp"
> > name="loginForm"
> > scope="request"
> > validate="true">
> > <forward name="success" path="/index.jsp"/>
> > <forward name="error" path="/login.jsp"/>
> > </action>
> >
> > 4) LoginForm.java
> > ....
> > public ActionErrors validate(ActionMapping
> > mapping,HttpServletRequest request) {
> >
> > ActionErrors errors = new ActionErrors();
> > if ((userID == null) || (userID.length() < 1))
> > errors.add("login", new
> > ActionError("error.userID.required"));
> > return errors;
> > }
> > ...
> >
> > 5) login.jsp
> > ...
> > <%@ taglib uri="/WEB-INF/taglibs/struts-html.tld" prefix="html" %>
> > ...
> > <html:errors/>
> > ...
> >
> >
> > Im not getting the errors tag to print anything to the page, but the
> > validation is returning it to the form properly.
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
> _________________________________________________________
>
> Do You Yahoo!?
>
> Get your free @yahoo.com address at http://mail.yahoo.com
>
> --
> 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 tag problem
Posted by Sean Owen <sr...@yahoo.com>.
I believe your web.xml needs to be more like this:
<init-param>
<param-name>application</param-name>
<param-value>com.myapp.web.ApplicationResources</param-value>
</init-param>
The ApplicationResources.properties should end up in the same directory as
the compiled .class files for com.myapp.web. I suggest you copy it there in
your build process. Anyhow this setup works for me.
Sean
----- Original Message -----
From: "Pete Serafin" <ps...@sbti.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, December 04, 2001 2:46 PM
Subject: Error tag problem
> All,
>
> I am having a similar problem to Binh
> (
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg18646.html
>
> ).
> I was wondering if anyone has a solution as to why I cannot get the
> <html:errors> tag to work. I did notice that Struts docs say:
>
> "In order to use this tag successfully, you must have defined an
> application scope MessageResources bean under the default attribute
> name, with at least the following message keys: errors.header,
> errors.footer "
>
> Where is the MessageResources bean instantiated and what is the "default
>
> name" mentioned?
>
> The following is how my app is set up according to my web.xml,
> ApplicationResources.properties, strtus-config.xml, and my ActionForm
> and jsp:
> 1) ApplicationResources.properties:
>
> errors.header=<ul>
> errors.footer=</ul>
>
> 2) web.xml
> ...
> <init-param>
> <param-name>application</param-name>
> <param-value>ApplicationResources</param-value>
> </init-param>
> ...
>
> 3)struts-config.xml
>
> <action path="/login" type="action.loginAction"
> input="/login.jsp"
> name="loginForm"
> scope="request"
> validate="true">
> <forward name="success" path="/index.jsp"/>
> <forward name="error" path="/login.jsp"/>
> </action>
>
> 4) LoginForm.java
> ....
> public ActionErrors validate(ActionMapping
> mapping,HttpServletRequest request) {
>
> ActionErrors errors = new ActionErrors();
> if ((userID == null) || (userID.length() < 1))
> errors.add("login", new
> ActionError("error.userID.required"));
> return errors;
> }
> ...
>
> 5) login.jsp
> ...
> <%@ taglib uri="/WEB-INF/taglibs/struts-html.tld" prefix="html" %>
> ...
> <html:errors/>
> ...
>
>
> Im not getting the errors tag to print anything to the page, but the
> validation is returning it to the form properly.
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>