Okay.  I found what is causing the setters not to be called.   I have an 
interceptor called ValueStackInterceptor (which is called prior to 
ParametersInterceptors) that is placing a String variable "browser" on the 
stack (please, see code below). If I comment out the line that places this 
variable on the stack (see below) everything works fine.  I am showing the 
Interceptor and the line of code that is causing a problem.

Can someone please help me understand what is the problem with this code?


-----------------------------------------

package com.softlagos.web.struts2.interceptor;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.xwork.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.softlagos.web.common.UserSession;
import com.softlagos.web.common.WebAppUtils;


/**
 * Interceptor object used to initialize the Struts 2 Value Stack with some 
state information (like the
 * browser variable) that is needed in the results.
 *
 * @author  Rubens Gomes
 * @version $Id: ValueStackInterceptor.java 3754 2011-02-03 00:39:46Z rgomes $
 */
public final class ValueStackInterceptor extends AbstractInterceptor
{
    private static final long serialVersionUID = 1;
    private static final Log logger = 
LogFactory.getLog(ValueStackInterceptor.class.getName());

    public ValueStackInterceptor()
    {
        super();
    }

    @Override
    public String intercept(final ActionInvocation invocation)
        throws Exception
    {
        HttpServletRequest request = ServletActionContext.getRequest();
        UserSession userSession = WebAppUtils.getUserSession(request);

        /*
         * The DetectUserAgentFilter code should be run prior to Struts 2 
filter because that filter
         * is responsible for setting the browser on the HTTP userSession 
session object.
         */
        if(userSession==null)
            throw new IllegalStateException("The userSession was not set.");

        if(StringUtils.isBlank(userSession.getBrowser()))
        {
            String msg = "The userSession browser is null, which means that the 
user agent detection failed.  Code cannot proceed at this point.";
            IllegalStateException ex = new IllegalStateException(msg);
            logger.error(msg, ex);
            throw ex;
        }
        if(logger.isInfoEnabled())
            logger.info("Setting Struts2 value stack browser [" + 
userSession.getBrowser() + "].");

        Map<String, Object> context = new HashMap<String, Object>();
        // browser is used on Result objects to render either a desktop or 
mobile JSP page.

        context.put("browser", userSession.getBrowser());

/*  ---- >>>  THE FOLLOWING LINE IS IMPACTING ON ACTION SETTER NOT TO BE CALLED 
<<< ---- */
        ActionContext.getContext().getValueStack().push(context);


        /* --- Reverse Path --- */
        return invocation.invoke();
    }
}


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

Reply via email to