This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Struts and the fly likes errors.add() question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "errors.add() question" Watch "errors.add() question" New topic
Author

errors.add() question

pradeep arum
Ranch Hand

Joined: Oct 01, 2003
Posts: 130
hi all,
I want to display errors directly without writing key, value pairs in the properties file, i want to pass a string of my choice to errors.add("fatal error ") and make the <html:error> pick up the error and display on the JSP page, i know there is a way with message resource in the web.xml, but i am not sure.please help.
thanks


SCJP1.4,SCBCD
Failure is not when you fall down; its only when you fail to get up again.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

I'm not sure that can be done without extending the framework.
You could always cheat and do:
ApplicationResources:
error.x = {0}

Action:
errors.add("x", new ActionError("error.x", "Don't do that again!");


A good workman is known by his tools.
pradeep arum
Ranch Hand

Joined: Oct 01, 2003
Posts: 130
i thoutght of this idea before, but i dont want the properties file.
thanks
Pradeep
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Like I said you'll have to extend the framework.

One way to do it is from MessagesTag. In the doStartTag() method find this:

and turn it to this:
String msg = report.getKey();
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi pradeep

I agree with marks idea of substitution if u use properties but if u overwrite the tag as he said that will make u loose the original behaviour of errors tag so better extend as i wrote in another post
 
Consider Paul's rocket mass heater.
 
subject: errors.add() question