Sunday, November 25, 2007

What are the differences between ActionErrors and ActionMessage?/What are the differences between Action.saveErrors(...) and Action.saveMessages(...)?

To summarize, the difference between the classes ActionErrors/ActionError/ActionMessages/ActionMessage has absolutely nothing to do with the difference in behavior in Action.saveErrors(...) and Action.saveMessages(...)

The difference between the classes is zero -- all behavior in ActionErrors was pushed up into ActionMessages and all behavior in ActionError was pushed up into ActionMessage. This was done in the attempt to clearly signal that these classes can be used to pass any kind of messages from the controller to the view -- errors being only one kind of message.

The difference between saveErrors(...) and saveMessages(...) is simply the attribute name under which the ActionMessages object is stored, providing two convenient default locations for storing controller messages for use by the view. If you look more closely at the html:errors and html:messages tags, you can actually use them to get an ActionMessages object from any arbitrary attribute name in any scope.

The difference between html:errors and html:messages is purely in syntax and model -- both tags *default* to look for an ActionMessages object under  Globals.ERROR_KEY despite the difference in names.html:messages provides more flexibility at the cost of more typing.

Courtsey:https://wiki.apache.org/struts/

1 comments :

DesiPhilosopher on October 11, 2008 at 3:40 PM said...

That was a nice explanation, thank you!

 

Disclaimer
Interview Questions On Java,Java EE Copyright © 2016. Reads: best tracker