You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dmitriy Kuznetsov <he...@yandex.ru> on 2007/04/20 21:56:37 UTC
How to force request parameters to be passed to action through
interceptor?
Hello!
I am using Struts 2.0.6. I have a simple form:
<form action="action-intercepted.action" method="get">
<input name="actionID" type="text" readonly value="4"></input>
<input type="submit" value="through interceptor"></input>
</form>
I have an action class SimpleAction with public setActionID(Long) and
getActionID() methods, that extends ActionSupport. And i have a void
interceptor class:
public class VoidInterceptor extends AbstractInterceptor {
public String intercept(ActionInvocation ai) throws Exception{
return ai.invoke();
}
}
At the end, i have following configuration in struts.xml:
<struts>
<package name="testMe" extends="struts-default">
<interceptors>
<interceptor name="voidInt"
class="myinterceptor.VoidInterceptor" />
</interceptors>
<action name="action-intercepted" class="SimpleAction">
<interceptor-ref name="voidInt"/>
<result type="velocity">/frame-res.vm</result>
</action>
</package>
</struts>
When i submit the simple form, the value of "actionID" input field (that
equals to 4) never reaches the action class and corresponding property in it
(that is intended to be set by public setActionID(Long)) remains null. But
if i exclude "<interceptor-ref name="voidInt"/>" from action configuration
in struts.xml, the sample starts to work as expected.
Could you please explain, what i should do to force any request parameter to
be passed to my action class through the interceptor successfully?
Thx.
--
View this message in context: http://www.nabble.com/How-to-force-request-parameters-to-be-passed-to-action-through-interceptor--tf3620324.html#a10109216
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: How to force request parameters to be passed to action through
interceptor?
Posted by Dmitriy Kuznetsov <he...@yandex.ru>.
Mark Menard wrote:
>
> On 4/20/07 3:56 PM, "Dmitriy Kuznetsov" <he...@yandex.ru> wrote:
>
>> <struts>
>> <package name="testMe" extends="struts-default">
>> <interceptors>
>> <interceptor name="voidInt"
>> class="myinterceptor.VoidInterceptor" />
>> </interceptors>
>>
>> <action name="action-intercepted" class="SimpleAction">
>> <interceptor-ref name="voidInt"/>
>
> I think this is your problem. Your voidInt interceptor is the only one
> that
> is being called for this action.
>
> The setting of parameters is done using an interceptor. By setting the
> interceptor for this action you've excluded it from the configuration.
>
> You need to create an interceptor stack that includes your custom
> interceptor as well as the interceptors for the params, model driven,
> workflow etc.
>
> Example:
>
> <package name="quadran-default" extends="struts-default">
> <interceptors>
>
> <interceptor name="qmenu" class="menuInterceptor" />
> <interceptor name="conversation-model-driven"
>
> class="net.vitarara.quadran.core.web.util.ConversationModelInterceptor"
> />
> <interceptor name="login" class="loginInterceptor" />
>
> <interceptor-stack name="defaultLoginStack">
> <interceptor-ref name="qmenu" />
> <interceptor-ref name="servlet-config" />
> <interceptor-ref name="params" />
> <interceptor-ref name="login" />
> <interceptor-ref name="conversation-model-driven" />
> <interceptor-ref name="prepare" />
> <interceptor-ref name="chain" />
> <interceptor-ref name="model-driven" />
> <interceptor-ref name="fileUpload" />
> <interceptor-ref name="static-params" />
> <interceptor-ref name="params" />
> <interceptor-ref name="conversionError" />
> <interceptor-ref name="validation" />
> <interceptor-ref name="workflow" />
>
> <!-- <interceptor-ref name="component" /> -->
> <!-- <interceptor-ref name="debugging" /> -->
> <!-- <interceptor-ref name="valuestack-debugger" /> -->
> </interceptor-stack>
> </interceptors>
> </package>
>
> Mark
>
Thank you for explaination, Mark. I did as you wrote and it works fine now.
--
View this message in context: http://www.nabble.com/How-to-force-request-parameters-to-be-passed-to-action-through-interceptor--tf3620324.html#a10112002
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: How to force request parameters to be passed to action
through interceptor?
Posted by Mark Menard <ma...@mjm.net>.
On 4/20/07 3:56 PM, "Dmitriy Kuznetsov" <he...@yandex.ru> wrote:
> <struts>
> <package name="testMe" extends="struts-default">
> <interceptors>
> <interceptor name="voidInt"
> class="myinterceptor.VoidInterceptor" />
> </interceptors>
>
> <action name="action-intercepted" class="SimpleAction">
> <interceptor-ref name="voidInt"/>
I think this is your problem. Your voidInt interceptor is the only one that
is being called for this action.
The setting of parameters is done using an interceptor. By setting the
interceptor for this action you've excluded it from the configuration.
You need to create an interceptor stack that includes your custom
interceptor as well as the interceptors for the params, model driven,
workflow etc.
Example:
<package name="quadran-default" extends="struts-default">
<interceptors>
<interceptor name="qmenu" class="menuInterceptor" />
<interceptor name="conversation-model-driven"
class="net.vitarara.quadran.core.web.util.ConversationModelInterceptor"
/>
<interceptor name="login" class="loginInterceptor" />
<interceptor-stack name="defaultLoginStack">
<interceptor-ref name="qmenu" />
<interceptor-ref name="servlet-config" />
<interceptor-ref name="params" />
<interceptor-ref name="login" />
<interceptor-ref name="conversation-model-driven" />
<interceptor-ref name="prepare" />
<interceptor-ref name="chain" />
<interceptor-ref name="model-driven" />
<interceptor-ref name="fileUpload" />
<interceptor-ref name="static-params" />
<interceptor-ref name="params" />
<interceptor-ref name="conversionError" />
<interceptor-ref name="validation" />
<interceptor-ref name="workflow" />
<!-- <interceptor-ref name="component" /> -->
<!-- <interceptor-ref name="debugging" /> -->
<!-- <interceptor-ref name="valuestack-debugger" /> -->
</interceptor-stack>
</interceptors>
</package>
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org