File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How to get a complete string from actionmessage in action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to get a complete string from actionmessage in action class" Watch "How to get a complete string from actionmessage in action class" New topic
Author

How to get a complete string from actionmessage in action class

Donald Fung
Greenhorn

Joined: Oct 27, 2004
Posts: 18
Hi all,

I wrote an action class to retrieve the records in an excel file and insert into database.
The action reads the records into an ArrayList of actiomform and check it by using validator in the action class.

If the actionform is invalid, I need to put the line number and the error into a log file and send back to the user.

However, the returned is ActionMessages which contains arguments. How can I convert it to a String to put into a file?

Hope someone can help. Thanks.
[ June 16, 2006: Message edited by: Donald Fung ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You can do this by taking advantage of some of the methods available to your Action class through it's superclass, the Struts Action class. The important methods are getResources() and getLocale(). The code below should accomplish what you want. In this code, the variable "errors" represents an ActionMessages instance.

[ June 16, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Donald Fung
Greenhorn

Joined: Oct 27, 2004
Posts: 18
I get it.
Thanks, Merrill.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get a complete string from actionmessage in action class
 
Similar Threads
Need immediate help, my job is stuck
Passed SCJD.
how to do "redirect-action" to some action from within ActionSupport?
problem in form action tag
BufferedReader into a String array