| Author |
errors.add() problem please help
|
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.
|
 |
sreenath reddy
Ranch Hand
Joined: Sep 21, 2003
Posts: 415
|
|
Hi There is no option for this in struts but still its a very good farmework taht u can have ur customerrors which extends actionerrors and write a mwthod which just takes string and at the same time u need to write a custom tag <cutom:errors/> CustomErrors will look like public class IwebErrors extends ActionErrors implements Serializable { public void add(String message) { ActionMessageItem item = (ActionMessageItem) messages.get("exception"); List list = null; if (item == null) { list = new ArrayList(); item = new ActionMessageItem(list, iCount++); messages.put("exception", item); } else { list = item.getList(); } list.add(new ActionError(message)); } } and in ur tah just do the same as html:errors but in between add if(message != null) { results.append(message); } else { results.append(report.getKey()); } where message is the value of the key in resource bundle i hope this would give a clue on how to go about
|
 |
 |
|
|
subject: errors.add() problem please help
|
|
|