You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shale.apache.org by Lucy Luo <Lu...@precash.com> on 2006/09/21 19:52:56 UTC

Problem in set an instance of AbstractViewController to HttpServletRequest object

Hi there,  
 
I updated the Shale Framwork from 1.0.1 version
(struts-shale-20060121.zip) to 1.0.4-SNAP
(shale-framework-20060917.zip), and found some problem.
  
In the old shale framework 1.0.1 version(struts-shale-20060121.zip), I
can get the HTTPServletRequest object form ExternalContext, then set a
new attribute( LucyTestVC extends AbstractViewController ) to the
HTTPServletRequest object.  After upgrade to the lastest version -
1.0.4-SNAP (shale-framework-20060917.zip), when I try to set a new
attribute(LucyTestVC) to the HTTPServletRequest object, the LucyTestVC
object is destroyed, then recreated, destroyed, recreated, destroyed....

It seems that we can not set an instance of AbstractViewController
object to HttpRequest object:  request.setAttribute("LucyTestVC", this)

Is any idea why we have this problem in latest version of Shale
Framework? And how to solve this problem. I have to put LucyTestVC
object to HTTPServletRequest object.

 
Here is the source code of LucyTestVC.java:
==============================
import org.apache.shale.view.AbstractViewController;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.servlet.http.HttpServletRequest;
 
public class LucyTestVC extends AbstractViewController {
    private static final Log LOGGER =
LogFactory.getLog(LucyTestVC.class);
    public void doInit() {
        LOGGER.debug(getClass() + " doInit()");
    }
    public void doPreprocess() {
        LOGGER.debug(getClass() + " doPreprocess()");
    }
    public void doPrerender() {
        LOGGER.debug(getClass() + " doPrerender()");
    }
    public void doDestroy() {
        LOGGER.debug(getClass() + " doDestroy()");
}
    public final void init() {
        LOGGER.debug("init()");

        super.init();

        HttpServletRequest request = getRequest();
        request.setAttribute("title", "LUCY Test");
        LOGGER.debug("Before set attribute LucyTestVC to
HttpServletRequest object");

       request.setAttribute("LucyTestVC", this); // problem in this line

        LOGGER.debug("After set attribute LucyTestVC to
HttpServletRequest object"); // this line of source code never be
called!!
        doInit();
    }
 
    public final void destroy() {
        LOGGER.debug("destroy()");
        super.destroy();
        doDestroy();
    }

    protected HttpServletRequest getRequest() {
        LOGGER.debug("getRequest()");
        HttpServletRequest request = (HttpServletRequest)
getExternalContext().getRequest();
        return request;
}
}  // end of LucyTestVC.java
 
Here is the output message:
======================
rocessor25] DEBUG com.prenet.presentation.DebugPhaseListener -
beforePhase(RESTORE_VIEW 1)
2006-09-20 16:49:30,071 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - init()
2006-09-20 16:49:33,821 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - getRequest()
2006-09-20 16:49:33,836 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - Before set
attribute LucyTestVC to HttpServletRequest object
2006-09-20 16:49:33,836 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - init()
2006-09-20 16:49:35,586 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - getRequest()
2006-09-20 16:49:35,586 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - Before set
attribute LucyTestVC to HttpServletRequest object
2006-09-20 16:49:35,586 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - destroy()
2006-09-20 16:49:35,586 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - class
com.prenet.mac.presentation.partnerSetup.LucyTestVC doDestroy()
2006-09-20 16:49:35,586 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - init()
2006-09-20 16:49:36,617 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - getRequest()
2006-09-20 16:49:36,617 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - Before set
attribute LucyTestVC to HttpServletRequest object
2006-09-20 16:49:36,617 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - destroy()
2006-09-20 16:49:36,617 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - class
com.prenet.mac.presentation.partnerSetup.LucyTestVC doDestroy()
2006-09-20 16:49:36,617 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - init()
2006-09-20 16:49:36,899 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - getRequest()
2006-09-20 16:49:36,899 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - Before set
attribute LucyTestVC to HttpServletRequest object
2006-09-20 16:49:36,899 [http-8080-Processor25] DEBUG
com.prenet.mac.presentation.partnerSetup.LucyTestVC - destroy()
 
Many thanks,
 
Lucy 


The information in this email may be confidential and/or privileged. This email is intended to be reviewed by only the individual or organization named above. If you are not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any review, dissemination or copying of this email and its attachments, if any, or the information contained herein is prohibited. If you have received this email in error, please immediately notify the sender by return email and delete this email from your system.