aspose file tools*
The moose likes Struts and the fly likes ActionError problems with Singleton Action Bean in Struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionError problems with Singleton Action Bean in Struts2" Watch "ActionError problems with Singleton Action Bean in Struts2" New topic
Author

ActionError problems with Singleton Action Bean in Struts2

Konstantin Netkachev
Greenhorn

Joined: Jul 24, 2009
Posts: 15
Hello,

I have problems with ActionErrors at Struts2.

Action I use is declared as singleton (by default).



And here is my action it struts.xml:



In "sell" method I add errors by addActionError and I'm getting into page with error message, it works good.
But when I (on this page with error) click any link to other action, I don't hit this action. Instead of it I receive message:

"No result defined for action action.ShipList and result input"
"The requested resource (No result defined for action action.ShipList and result input) is not available."


For example, I'm clicking a link on the page with errormessage.

Here is a link:



And here is an Action:



I set a brakepoint in the myShips method, but don't reach it.
Instead I receive that errormessages.

So what should I do to overcome this problem?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Don't use singleton actions.

The framework is designed around using action-per-request.
Konstantin Netkachev
Greenhorn

Joined: Jul 24, 2009
Posts: 15
But this Action contains ArrayList, which is initialized once by reading Database.
I don't want to init this list again every time I hit this Action. That's why I use Singleton.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Besides there being other ways to deal with that issue, what I'm telling you is fundamentally correct: S2 is designed to use an action-per-request.

If you work against that design principle you will have to work around the framework--an approach I don't recommend.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ActionError problems with Singleton Action Bean in Struts2
 
Similar Threads
Localization with Struts2 help, not persisting to any other pages
Interceptor messes up action class in Struts2
Struts2 and Spring integration
Problem With I18n feature of Struts2
struts2 properties file reload