struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sridhar Reddy T (JIRA)" <j...@apache.org>
Subject [jira] Updated: (WW-2682) Plugin not working in Portal environment
Date Wed, 25 Jun 2008 05:33:06 GMT

     [ https://issues.apache.org/struts/browse/WW-2682?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sridhar Reddy T updated WW-2682:
--------------------------------


StrutsTilesRequestContext.java  

1) Added one more condition - include.endsWith(".jsp")

  public void dispatch(String include) throws IOException {
    	if (include.endsWith(mask) || include.endsWith(".jsp")) {
            // FIXME This way FreeMarker results still don't have a content-type!
    	    include(include);
        } else {
            super.dispatch(include);
        }
    }

2) Added 2 more lines in else part of include().
        	HttpServletResponse response = (HttpServletResponse) getResponse();
        	response.setContentType("text/html");

    public void include(String include) throws IOException {
        if (include.endsWith(mask)) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Intercepting tiles include '" + include + "'. Processing as freemarker
result.");
            }
            HttpServletRequest request = (HttpServletRequest) getRequest();
            HttpServletResponse response = (HttpServletResponse) getResponse();

            ActionInvocation invocation =
                    ServletActionContext.getActionContext(request).getActionInvocation();

            try {
                FreemarkerResult result = new FreemarkerResult();
                result.setWriter(response.getWriter());

                Container container = Dispatcher.getInstance()
                        .getConfigurationManager()
                        .getConfiguration().getContainer();

                container.inject(result);

                result.doExecute(include, invocation);
            } catch (Exception e) {
                LOG.error("Error invoking Freemarker template", e);
                throw new IOException("Error invoking Freemarker template." + e.getMessage());
            }
        } else {
        	HttpServletResponse response = (HttpServletResponse) getResponse();
        	response.setContentType("text/html");
                     super.include(include);
        }
    }


> Plugin not working in Portal environment
> ----------------------------------------
>
>                 Key: WW-2682
>                 URL: https://issues.apache.org/struts/browse/WW-2682
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Tiles
>    Affects Versions: 2.0.11.1
>         Environment: Struts 2.0.11.1, Tiles 2.0.6, Tiles Plugin 2.0.11.1
>            Reporter: Sridhar Reddy T
>            Assignee: Sridhar Reddy T
>         Attachments: StrutsTilesRequestContext.java
>
>
> When i try to use Tiles in Portlet environment using the above versions, it does not
work.  I have done some research and these are my findings.
> ( Step 1) CODE BASE - TILES PLUGIN 2.0.11.1
> In org.apache.struts2.tiles.StrutsTilesRequestContext, this logic is such that it always
calls dispatch(), if mask is not ending with ".ftl".
>  public void dispatch(String include) throws IOException {
>     	if (include.endsWith(mask)) {
>             // FIXME This way FreeMarker results still don't have a content-type!
>     	    include(include);
>         } else {
>             super.dispatch(include);
>         }
>     }
> ( Step 2) CODE BASE - TILES 2.0.6
> super.dispatch() in the above code calls org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch()
>     public void dispatch(String path) throws IOException {
>         if (response.isCommitted() || ServletUtil.isForceInclude(request)) {
>             include(path);
>         } else {
>             forward(path);
>         }
>     }
> Atleast above logic should have worked to call include(), if ServletUtil.isForceInclude(request)
returned true.
> ServletUtil.isForceInclude(request) returns true if request.getAttribute(ServletUtil.FORCE_INCLUDE_ATTRIBUTE_NAME)
= =true.
> ( Step 3) CODE BASE - STRUTS 2.0.11.1
> Call to org.apache.struts2.portlet.servlet.PortletServletRequestDispatcher.doForward()
throws IllegalStateException.
> 	public void forward(ServletRequest request, ServletResponse response) throws ServletException,
IOException {
> 		throw new IllegalStateException("Not allowed in a portlet");
> 		
> 	}
> My guess is, forward() should not be called when the result is of type TilesResult. 
> My guess is that  we need a fix in  Step 1.
> EITHER 
>         call super.include() instead of calling dispatch() 
> OR
>         request.setAttribute("org.apache.tiles.servlet.context.ServletTilesRequestContext.FORCE_INCLUDE",
new Boolean(true)) before calling super.dispatch().
> Thanks,
> Sridhar.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message