You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Security Management <li...@secmgmt.com> on 2009/02/26 19:36:16 UTC

Problem with store interceptor

Here's my struts.xml, partially

	<interceptors>
			<interceptor name="loggedIn"
class="com.secmgmt.struts2.interceptors.LoggedInInterceptor"/>
			<interceptor-stack name="defaultSMCStack">
				<interceptor-ref name="store">
					<param
name="operationMode">AUTOMATIC</param>
				</interceptor-ref>
				<interceptor-ref name="defaultStack"/>
			</interceptor-stack>

			<interceptor-stack name="defaultLoggedInStack">
				<interceptor-ref name="createSession"/>
				<interceptor-ref name="loggedIn"/>
				<interceptor-ref name="defaultSMCStack"/>
			</interceptor-stack>
	</interceptors>

	<default-interceptor-ref name="defaultLoggedInStack" />

    <default-action-ref name="home" />

	<global-results> 
		<result name="login" type="redirectAction"> 
	        <param name="actionName">home</param> 
      	  <param name="namespace">/default</param> 
		</result> 
	</global-results>


Here's my LoggedInInteceptor code:

public String intercept(ActionInvocation ai) throws Exception
        {
            if(this.getSession() == null)
            {
                throw new Exception("Session is null");
            }
            
            if(this.getSession().get("username") != null)
            {
                String res = ai.invoke();
                return res;
                    
            }
            else
            {
                l.warn("LoggedInInterceptor didn't see a seession
username");
                addActionError(ai, "You must be authenticated to access this
page");
                return "login";
            }
        }

    private void addActionError(ActionInvocation invocation, String message)
        {
            Object action = invocation.getAction();
            if(action instanceof ValidationAware)
            {
                l.warn("Adding error message");
                ((ValidationAware) action).addActionError(message);
            }
            else
            {
                l.error("Action is not ValidationAware...");
            }
        }


I see in the catalina.out that it's adding an action error, but the redirect
action is stripping it (store interceptor should be saving/reload it,
right??), and it's not showing up after the global result runs and redirects
to the home action.

Any ideas?


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org