You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Yan Zhu <ya...@ipacc.com> on 2003/07/11 23:59:18 UTC

question about ActionErrors

    It's my understanding that ActionErrors builds a property/message
list based on the Apppiation.Properties file found in the classpath.
Is there anyway to change that behavior so that it can read of a file
that application specifies?

    Also, ActionErrors handles the displaying of the error messages
quite well. But what if I simply want to pass a status message back
to the users based on my action. Is there an equivalent of
ActionStatues?
For example, if I add a user to the db, I want the page to return to the

add user jsp after each add, with a message like user blah is added
successfully. It operates exactly like the errors, except it shows up
when actions are successful.

    thx

yan



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: question about ActionErrors

Posted by Yan Zhu <ya...@ipacc.com>.
great, thanks a lot!


Peter Smith wrote:

> Hi Yan,
>
> For your properties file, there is an entry in struts-config that you can
> make.  Here is an example:
>
> <!-- == Message Resources Definitions ================================== -->
>   <message-resources parameter="your.package.tree.application"
>                      null="false"/>
>
> For this example, the file would be application.properties.
>
> For your other questions, there is an ActionMessages class that does what
> you need.
>
> HTH, Peter
> --
> Peter Smith
> Software Engineer
> InfoNow Corporation
>
> > From: Yan Zhu <ya...@ipacc.com>
> > Reply-To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Date: Fri, 11 Jul 2003 16:59:18 -0500
> > To: Struts Users Mailing List <st...@jakarta.apache.org>
> > Subject: question about ActionErrors
> >
> >
> >   It's my understanding that ActionErrors builds a property/message
> > list based on the Apppiation.Properties file found in the classpath.
> > Is there anyway to change that behavior so that it can read of a file
> > that application specifies?
> >
> >   Also, ActionErrors handles the displaying of the error messages
> > quite well. But what if I simply want to pass a status message back
> > to the users based on my action. Is there an equivalent of
> > ActionStatues?
> > For example, if I add a user to the db, I want the page to return to the
> >
> > add user jsp after each add, with a message like user blah is added
> > successfully. It operates exactly like the errors, except it shows up
> > when actions are successful.
> >
> >   thx
> >
> > yan
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: question about ActionErrors

Posted by Yan Zhu <ya...@ipacc.com>.
nevermind, the source code for PropertyResourceMessages is good enough.

thanks!

yan

Yan Zhu wrote:

> I like all the features currently implemented in the PropertyMessageResources.
> It just seems a bit odd to me that the only way implemented is to look
> for the property file in the classpath, and you don't have a way to specify
> the path to the file. Is there an example of extending that class for your own
> use
> anywhere I can take a look at?
>
> thanks!
>
> yan
>
> Jing Zhou wrote:
>
> > ----- Original Message -----
> > From: "Yan Zhu" <ya...@ipacc.com>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Saturday, July 12, 2003 9:10 AM
> > Subject: Re: question about ActionErrors
> >
> > >
> > > I might be wrong about this, but doesn't this still force it to look for
> > files
> > > in app's classpath, such as in directories like WEB-INF/classes or /lib ?
> > >
> > > I need to load the property file from WEB-INF/conf/myapp.message,
> > > how would I do that?
> >
> > You might have to create a custom version of PropertyMessageResources.
> > In the class, you use ServletContext.getResourceAsStream to obtain a
> > input stream with a context relative path and then use it to initialize the
> > properties.
> >
> > Before you go down that path, evaluate the benefits of the current
> > PropertyMessageResources. It allows you to group message resources
> > into different packages. It is easy to tell, say a message format like
> >
> > key34= Input {0} is invalid
> >
> > is specified for which classe and in which package. This is very useful when
> > your project get larger. Of course, there are other better organization
> > structures. Some people think storing message resources in database
> > is a good way. I am interested in that direction for larger projects.
> >
> > >
> > > thanks
> > >
> > > yan
> > >
> >
> > Jing
> > Netspread Carrier
> > http://www.netspread.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: question about ActionErrors

Posted by Yan Zhu <ya...@ipacc.com>.
I like all the features currently implemented in the PropertyMessageResources.
It just seems a bit odd to me that the only way implemented is to look
for the property file in the classpath, and you don't have a way to specify
the path to the file. Is there an example of extending that class for your own
use
anywhere I can take a look at?

thanks!

yan


Jing Zhou wrote:

> ----- Original Message -----
> From: "Yan Zhu" <ya...@ipacc.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Saturday, July 12, 2003 9:10 AM
> Subject: Re: question about ActionErrors
>
> >
> > I might be wrong about this, but doesn't this still force it to look for
> files
> > in app's classpath, such as in directories like WEB-INF/classes or /lib ?
> >
> > I need to load the property file from WEB-INF/conf/myapp.message,
> > how would I do that?
>
> You might have to create a custom version of PropertyMessageResources.
> In the class, you use ServletContext.getResourceAsStream to obtain a
> input stream with a context relative path and then use it to initialize the
> properties.
>
> Before you go down that path, evaluate the benefits of the current
> PropertyMessageResources. It allows you to group message resources
> into different packages. It is easy to tell, say a message format like
>
> key34= Input {0} is invalid
>
> is specified for which classe and in which package. This is very useful when
> your project get larger. Of course, there are other better organization
> structures. Some people think storing message resources in database
> is a good way. I am interested in that direction for larger projects.
>
> >
> > thanks
> >
> > yan
> >
>
> Jing
> Netspread Carrier
> http://www.netspread.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: question about ActionErrors

Posted by Jing Zhou <ji...@netspread.com>.
----- Original Message ----- 
From: "Yan Zhu" <ya...@ipacc.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Saturday, July 12, 2003 9:10 AM
Subject: Re: question about ActionErrors


>
> I might be wrong about this, but doesn't this still force it to look for
files
> in app's classpath, such as in directories like WEB-INF/classes or /lib ?
>
> I need to load the property file from WEB-INF/conf/myapp.message,
> how would I do that?

You might have to create a custom version of PropertyMessageResources.
In the class, you use ServletContext.getResourceAsStream to obtain a
input stream with a context relative path and then use it to initialize the
properties.

Before you go down that path, evaluate the benefits of the current
PropertyMessageResources. It allows you to group message resources
into different packages. It is easy to tell, say a message format like

key34= Input {0} is invalid

is specified for which classe and in which package. This is very useful when
your project get larger. Of course, there are other better organization
structures. Some people think storing message resources in database
is a good way. I am interested in that direction for larger projects.


>
> thanks
>
> yan
>

Jing
Netspread Carrier
http://www.netspread.com



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: question about ActionErrors

Posted by Yan Zhu <ya...@ipacc.com>.
I might be wrong about this, but doesn't this still force it to look for files
in app's classpath, such as in directories like WEB-INF/classes or /lib ?

I need to load the property file from WEB-INF/conf/myapp.message,
how would I do that?

thanks

yan


Peter Smith wrote:

> Hi Yan,
>
> For your properties file, there is an entry in struts-config that you can
> make.  Here is an example:
>
> <!-- == Message Resources Definitions ================================== -->
>   <message-resources parameter="your.package.tree.application"
>                      null="false"/>
>
> For this example, the file would be application.properties.
>
> For your other questions, there is an ActionMessages class that does what
> you need.
>
> HTH, Peter
> --
> Peter Smith
> Software Engineer
> InfoNow Corporation
>
> > From: Yan Zhu <ya...@ipacc.com>
> > Reply-To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Date: Fri, 11 Jul 2003 16:59:18 -0500
> > To: Struts Users Mailing List <st...@jakarta.apache.org>
> > Subject: question about ActionErrors
> >
> >
> >   It's my understanding that ActionErrors builds a property/message
> > list based on the Apppiation.Properties file found in the classpath.
> > Is there anyway to change that behavior so that it can read of a file
> > that application specifies?
> >
> >   Also, ActionErrors handles the displaying of the error messages
> > quite well. But what if I simply want to pass a status message back
> > to the users based on my action. Is there an equivalent of
> > ActionStatues?
> > For example, if I add a user to the db, I want the page to return to the
> >
> > add user jsp after each add, with a message like user blah is added
> > successfully. It operates exactly like the errors, except it shows up
> > when actions are successful.
> >
> >   thx
> >
> > yan
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: question about ActionErrors

Posted by Peter Smith <ps...@infonow.com>.
Hi Yan,

For your properties file, there is an entry in struts-config that you can
make.  Here is an example:

<!-- == Message Resources Definitions ================================== -->
  <message-resources parameter="your.package.tree.application"
                     null="false"/>

For this example, the file would be application.properties.

For your other questions, there is an ActionMessages class that does what
you need.

HTH, Peter
-- 
Peter Smith
Software Engineer
InfoNow Corporation

> From: Yan Zhu <ya...@ipacc.com>
> Reply-To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Date: Fri, 11 Jul 2003 16:59:18 -0500
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: question about ActionErrors
> 
> 
>   It's my understanding that ActionErrors builds a property/message
> list based on the Apppiation.Properties file found in the classpath.
> Is there anyway to change that behavior so that it can read of a file
> that application specifies?
> 
>   Also, ActionErrors handles the displaying of the error messages
> quite well. But what if I simply want to pass a status message back
> to the users based on my action. Is there an equivalent of
> ActionStatues?
> For example, if I add a user to the db, I want the page to return to the
> 
> add user jsp after each add, with a message like user blah is added
> successfully. It operates exactly like the errors, except it shows up
> when actions are successful.
> 
>   thx
> 
> yan
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org