Fetching an ActionError from ActionErrors using html:errors tag
5 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Juha_Siltanen
Posted On:   Wednesday, May 12, 2004 08:20 AM

Within an Action-class in a catch-block, I have the following... ActionErrors errors = new ActionErrors(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("my_error_message")); saveErrors(request, errors); return mapping.findForward("failure"); And in the tiles-defined jsp page, I have the following... <%= ActionErrors.GLOBAL_ERROR %>" property="my_error_message"/> And in my ApplicationResources.properties I have the following.... my_error_message=error occured! The problem is, I c   More>>

Within an Action-class in a catch-block, I have the following...



ActionErrors errors = new ActionErrors();

errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("my_error_message"));

saveErrors(request, errors);

return mapping.findForward("failure");



And in the tiles-defined jsp page, I have the following...



<%= ActionErrors.GLOBAL_ERROR %>" property="my_error_message"/>


And in my ApplicationResources.properties I have the following....



my_error_message=error occured!


The problem is, I can't seem to access this one particular error message in the jsp page. Furthermore, if I put this on my jsp page...



<%= ActionErrors.GLOBAL_ERROR %>"/>



Nothing prints out. But if I change it to...



<%= Globals.ERROR_KEY %>" />



It prints out 'my_error_message' along with all the other messages. As I want to display different error messages on different locations within the jsp page, this will not do. I need to access each error message one by one.


What am I doing wrong? I apprechiate all the help I can get. Thanks!

   <<Less

Re: Fetching an ActionError from ActionErrors using html:errors tag

Posted By:   sheetal_bhandari  
Posted On:   Thursday, May 13, 2004 01:23 PM

Hi Pls do the following on ur jsp page

It will work
-regards Sheetal

Re: Fetching an ActionError from ActionErrors using html:errors tag

Posted By:   Siddharth_Prasad  
Posted On:   Wednesday, May 12, 2004 04:24 PM

hi


using




isnt printing my errors


i verified there is a request attribute



org.apache.struts.action.ERROR:org.apache.struts.action.ActionErrors@8497f6

with 2 properties


property error1:

property error2:

i'm printing them out on the console


Thanks,
Sid

Re: Fetching an ActionError from ActionErrors using html:errors tag

Posted By:   Christopher_Koenigsberg  
Posted On:   Wednesday, May 12, 2004 01:23 PM

Put the same "property" attribute on your html:errors, that you gave it in your "errs.add ... and vice versa! If you want to get a "property='my_error_message'" in the html:errors tag, then you have to add an error for this property, as the first argument to the errors.add! (not for "GLOBAL_ERROR")

Re: Fetching an ActionError from ActionErrors using html:errors tag

Posted By:   sheetal_bhandari  
Posted On:   Wednesday, May 12, 2004 08:59 AM

Hi
Pls do the following on ur jsp page


It will work

-regards
Sheetal

Re: Fetching an ActionError from ActionErrors using html:errors tag

Posted By:   Juha_Siltanen  
Posted On:   Wednesday, May 12, 2004 08:26 AM

I just wanted to add this: Just before I execute the return statement in my action class, I printed the contents of the ActionErrors object:


values from a single ActionError object:

key = my_error_message

values = null


The properties of ActionErrors:

org.apache.struts.action.GLOBAL_ERROR


Why can't I find this error in my jsp-page?


Thanks,
BR Juha

About | Sitemap | Contact