views:

36

answers:

0

Hello fellow geeks,

I have a problem with Struts2's ScopeInterceptor: after the action that is set to be the end of a workflow is executed the interceptor doesn't clear the session for the element that was set at the beginning.

This is how I have set up my classes and struts.xml:

struts.xml

<package name="build" extends="base-package,json-default" namespace="/build">
    <interceptors>
        <interceptor-stack name="buildStack">
            <interceptor-ref name="scope">
                <param name="session">model</param>
                <param name="key">partialBuild</param>
            </interceptor-ref>
            <interceptor-ref name="securedBasicStack" />
        </interceptor-stack>
    </interceptors>
    <default-interceptor-ref name="buildStack" />
    <action name="initiateBuild" class="uar.struts.actions.build.BaseBuildAction">
        <interceptor-ref name="buildStack">
            <param name="scope.type">start</param>
        </interceptor-ref>
        <result name="success" type="redirectAction">createNew</result>
    </action>
    .
    .
    .
    <action name="completeBuild" class="uar.struts.actions.build.CompleteBuildAction">
        <interceptor-ref name="buildStack">
            <param name="scope.type">end</param>
        </interceptor-ref>
        <result name="success" type="redirect">
            <param name="location">/home</param>
        </result>
    </action>
</package>

BaseAction

public class BaseAction extends ActionSupport {
}

BaseBuildAction

public class BaseBuildAction extends BaseAction implements
    ModelDriven<BuildDTO>, SessionAware {

private static final long serialVersionUID = -6193582942521444L;
protected BuildDTO build = null;
private Map<String, Object> sessionMap;

@Override
public BuildDTO getModel() {
    return build;
}

public void setModel(BuildDTO model) {
    this.build = model;
}

@Override
public void setSession(Map<String, Object> session) {
    this.sessionMap = session;      
}

public Map<String, Object> getSessionMap() {
    return sessionMap;
}
}

CompleteBuildAction

public class CompleteBuildAction extends BaseBuildAction {

public String execute() throws Exception {
         // do some stuff here
         return SUCCESS;
    }
}

Did I do something wrong? What amazes me is the fact that the interceptor works for putting that object into the session but fails to remove it. Any clues?

Thank you!