sgzwiz / jsonplugin

Automatically exported from code.google.com/p/jsonplugin
0 stars 1 forks source link

Struts 2 interceptors are not called when SMD method is called from dojo script #77

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The Dojo JSON RPC call instantiate the action class and all the 
interceptors are called as mentioned in action definition in struts.xml. 
When action class method( annotate with SMDMethod) is called another 
instance of action class is created , but no interceptors are called this 
time. I guess as there is no action definition for SMDMethod annotated 
method in struts.xml, no interceptors are called. 

But I want all the configured interceptors to be called when SMDMethod 
annotated method is called. 

My question how to achieve this.

Your help is urgently needed.

Original issue reported on code.google.com by rajibj...@gmail.com on 6 Jan 2009 at 6:56

GoogleCodeExporter commented 9 years ago
In your struts xml file, you can setup multiple interceptors to be used for your
action (i.e., paramsPrepareParamsStack and json in my example below). If you are
doing this for several actions, you may want to specify a package in your 
struts xml
file that all your "smd" actions use. There, you can specify a "default" 
interceptor
stack that calls all the interceptors you want. Then, all your "smd" actions 
can just
use the defaults.

Example of package which defines defaults for my actions using smd.
    <package name="jsonSmd" namespace="" extends="json-default">
      <result-types>
        <!-- override this "json" result-type from json plugin with custom
settings/defaults -->
        <result-type name="json" class="com.googlecode.jsonplugin.JSONResult"
default="true" >
          <param name="enableSMD">true</param>
          <param name="enableGZIP">true</param>
      </result-type>
      </result-types>
      <interceptors>
        <interceptor-stack name="jsonSmdStack">
          <interceptor-ref name="paramsPrepareParamsStack"></interceptor-ref>
          <interceptor-ref name="json">
            <param name="enableSMD">true</param>
          </interceptor-ref>
        </interceptor-stack>
      </interceptors>      
      <default-interceptor-ref name="jsonSmdStack"/>
    </package>

    <package name="myTestPackage" namespace="/test" extends="jsonSmd">
        <action name="testSMD" class="com.test.TestSMDAction" method="smd">
            <result name="success" />
        </action>
    </package>

Original comment by bsennin...@gmail.com on 7 Jan 2009 at 8:39

GoogleCodeExporter commented 9 years ago
very well explained by  bsenninger@, thanks!

Original comment by musa...@gmail.com on 28 Jul 2009 at 5:10