(Using Struts 2.1.2) I have a little "widget" (for want of a better word) which gets activated on most pages by a call to:
<s:action name="myWidget" namespace="/widgets" executeResults="true" /> the result of that action being a small JSP that will sit snuggly inside its little box on the overall page. That little widget is, in effect, independent and clueless of its surroundings, and very happy for it all. The sole job of the MyWidgetAction is gather the latest results and make these available to the widget through a getResults() method. Here is its original entry in struts.xml: <package name="widgets" extends="default" abstract="false" namespace="/widgets"> <action name="myWidget" class="com.mysite.MyWidgetAction"> <result>widget.jsp</result> </action> </package> The problem occurs when the widget appears on a JSP page with a form. When the user submits that form, if the ensuing action generates the INPUT result (say, because there was a problem with the content of the form), the JSP form page gets redisplayed, but it's clear that MyWidgetAction is not called anew, and Struts2 complains: ERROR ActionComponent:28 - Could not execute action: /widgets/myWidget No result defined for action com.infloox.tango.teaser.TeaserAction and result input If, on the other hand, I change the widget's result mapping (so as to catch results under any name): <action name="myWidget" class="com.mysite.MyWidgetAction"> <result name="*">widget.jsp</result> </action> I then get the following error: WARN OgnlValueStack:50 - Caught an exception while evaluating expression 'results' against value stack Caught an Ognl exception while getting property results - Class: ognl.OgnlRuntime File: OgnlRuntime.java Method: getMethodValue Line: 935 - ognl/OgnlRuntime.java:935:-1 ... Caused by: ognl.OgnlException: results [java.lang.NullPointerException] ... ("results" being the property on MyWidgetAction (with a getResults() getter) which gets called by widget.jsp.) I suppose one solution would be to put the results of MyWidget on the session; on an INPUT result, at least something would get displayed (even though not the latest results). But using the session like that seems to go against Struts2's philosophy... Another (prospective) option would be to involve AJAX over this question. Alternatively, is there a way to force a re-execution of that specific <s:action name="widget">?