Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java Open Source > Struts
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Struts section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 18th, 2006, 08:27 AM
Registered User
 
Join Date: Jan 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Difference between addErrors() and saveErrors()

What is the difference between addErrors() and saveErrors() in Action class of struts framework ?

M Kalyan Tilak
 
Old February 15th, 2006, 03:04 AM
Registered User
 
Join Date: Feb 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello sir this ram kishore (vrc)my mail ID is:[email protected]

k.ram kishore
 
Old February 15th, 2006, 03:02 PM
Authorized User
 
Join Date: Jan 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to longjava
Default

They are pretty much doing the same thing by adding the error messages to the container object(ActionMessages), and store the container object to the request's attribute name Globals.ERROR_KEY.

Here is a different:
The addErrors() method will append the error messages to the ActionMessages object if the ActionMessages object existed in the request object.

The saveErrors() method will replace the existing ActionMessages object with the new one that is passing in as an arugment to the method, instead of append it.

Here is a example showing the code fragment of their implemntation:

addErrors(HttpServletRequest request, ActionMessages errors)
{
  // ....
  ActionMessages requestErrors = (ActionMessages)request.getAttribute(Globals.ERROR _KEY);
  if (requestErrors == null) {
     requestErrors = new ActionMessages();
  }

  requestErrors.add(errors);
  // ....
}

saveErrors(HttpServletRequest request, ActionMessages errors)
{
  //.....
  request.setAttribute(Globals.ERROR_KEY, errors);
}

Hope this help.






Similar Threads
Thread Thread Starter Forum Replies Last Post
ch10 action.saveErrors() AlienLoi BOOK: Professional Jakarta Struts 0 May 11th, 2007 04:37 AM
Difference ashu .NET Framework 1.x 1 March 27th, 2007 09:46 AM
Difference between / vs ./ vs ../ arulkumar ASP.NET 2.0 Basics 1 February 21st, 2007 12:19 PM
diffrence between addErrors&saveErrors challagonda Struts 3 November 13th, 2006 07:37 AM
what is the difference between... chuck_schuldiner Javascript 2 February 10th, 2005 01:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.