tags:

views:

139

answers:

1

Hi, i have a problem with Struts2

This is my action configuration, before executing the roleDete in the Action, the interceptor is call, but after this, the values of the input are lost, there is no id to delete, if i remove the interceptor then the id to delete exist, could some one guide me to solve this?

<action name="roleDelete" method="roleDelete" class="com.webapp.role.action.RoleAction">
  <interceptor-ref name="validateUser"/>
  <result name="input" type="tiles">usertypePage</result>
  <result name="success" type="redirect">usertypeForm</result>
</action>

Thanks

+1  A: 

It sounds like you've defined a custom validateUser interceptor stack that doesn't include a required Struts 2 interceptor. By default, Struts 2 invokes the following interceptors on every request unless you define your own stack (as you've done):

        <interceptor-stack name="defaultStack">
            <interceptor-ref name="exception"/>
            <interceptor-ref name="alias"/>
            <interceptor-ref name="servletConfig"/>
            <interceptor-ref name="i18n"/>
            <interceptor-ref name="prepare"/>
            <interceptor-ref name="chain"/>
            <interceptor-ref name="debugging"/>
            <interceptor-ref name="scopedModelDriven"/>
            <interceptor-ref name="modelDriven"/>
            <interceptor-ref name="fileUpload"/>
            <interceptor-ref name="checkbox"/>
            <interceptor-ref name="multiselect"/>
            <interceptor-ref name="staticParams"/>
            <interceptor-ref name="actionMappingParams"/>
            <interceptor-ref name="params">
              <param name="excludeParams">dojo\..*,^struts\..*</param>
            </interceptor-ref>
            <interceptor-ref name="conversionError"/>
            <interceptor-ref name="validation">
                <param name="excludeMethods">input,back,cancel,browse</param>
            </interceptor-ref>
            <interceptor-ref name="workflow">
                <param name="excludeMethods">input,back,cancel,browse</param>
            </interceptor-ref>
        </interceptor-stack>

My advice would be to go through the above list and add them back in one at a time until you figure out which you need to properly populate your request variable. You can read more about interceptors in the Struts 2 docs.

Pat
+1 It is probably the "params" interceptor, which iterates through the request parameters and sets them on your action, i.e. calls the methods like setId() on your action.
Todd Owen