Announcement Announcement Module
No announcement yet.
Webflow with JSP/Tiles - Portlet has no content Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Webflow with JSP/Tiles - Portlet has no content

    Hi all,

    I am creating a portlet application with Spring Webflow (2.2.1) and JSP/Tiles (2.2.2).

    Everything works without any error. The problem I have is that the portlet does not show any content.
    I only see the title and no content (see attached picutre).
    And the console output of the liferay/tomcat server is:
    10:15:08.330 [http-8080-2] DEBUG o.s.w.c.i.SessionBindingConversationManager - Unlocking conversation 1
    10:15:08.330 [http-8080-2] DEBUG o.s.web.portlet.DispatcherPortlet - Null ModelAndView returned to DispatcherPortlet with name 'testproject': assuming HandlerAdapter completed request handling
    10:15:08.330 [http-8080-2] DEBUG o.s.web.portlet.DispatcherPortlet - Successfully completed request

    Here are my config files:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="" xmlns:xsi=""
    	<!-- - Location of the XML file that defines the root application context 
    		- Applied by ContextLoaderListener. -->
    	<!-- - Loads the root application context of this web app at startup. - 
    		The application context is then available via - WebApplicationContextUtils.getWebApplicationContext(servletContext). -->
    	<!-- Supports view rendering -->
    	<servlet> <!-- ViewRendererServlet is a bridge servlet, mainly for the Portlet MVC 
    			support. -->
    		<taglib id="PortletTLD">
    <?xml version="1.0" encoding="ISO-8859-1"?>
    	version="1.0" xmlns:xsi=""
    			<title>Test Portlet</title>
    applicationCtx portlet-config.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns=""
    	xmlns:xsi="" xmlns:webflow=""
    	<!-- Maps portlet modes to handlers -->
    	<bean id="portletModeHandlerMapping"
    		<property name="portletModeMap">
    				<entry key="view">
    						class="testproject.portlet.flowHandler.ViewFlowHandler" />
    	<bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver">
    		<property name="viewClass"
    			value="org.springframework.webflow.mvc.view.FlowAjaxTilesView" />
    	<!-- Plugs in a custom creator for Web Flow views -->
    	<webflow:flow-builder-services id="flowBuilderServices"
    		view-factory-creator="mvcViewFactoryCreator" />
    	<!-- Configures Web Flow to use Tiles to create views for rendering; Tiles 
    		allows for applying consistent layouts to your views -->
    	<bean id="mvcViewFactoryCreator"
    		<property name="viewResolvers" ref="tilesViewResolver" />
    	<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    		<property name="definitions">
    	<!-- Enables FlowHandlers -->
    	<bean class="org.springframework.webflow.mvc.portlet.FlowHandlerAdapter">
    		<property name="flowExecutor" ref="flowExecutor" />
    	<!-- Default flow executor -->
    	<webflow:flow-executor id="flowExecutor"
    		flow-registry="flowRegistry" />
    	<!-- The registry of executable flow definitions -->
    	<webflow:flow-registry id="flowRegistry"
    		flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows">
    		<webflow:flow-location-pattern value="/**/*-flow.xml" />
    	<!-- Validators -->
    	<bean id="personValidator"
    		class="testporject.portlet.validator.PersonValidator" />
    Application Ctx applicationContext.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns=""
    	<bean id="personService" class="testproject.service.impl.PersonServiceImpl" />
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE tiles-definitions PUBLIC
           "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
    	<definition name="portletgreet" template="/WEB-INF/tiles/layouts/refarchgreet.jsp">
    		<put-attribute name="input" value="/WEB-INF/tiles/layout/input.jsp" />
    		<put-attribute name="greet" value="/WEB-INF/tiles/layout/greet.jsp" />
    	<definition name="portletclone" template="/WEB-INF/tiles/layouts/refarchclone.jsp">
    		<put-attribute name="input" value="/WEB-INF/tiles/layout/input.jsp" />
    		<put-attribute name="cloned" value="/WEB-INF/tiles/layout/cloned.jsp" />
    <?xml version="1.0" encoding="UTF-8"?>
    <flow xmlns=""
    	<var name="person" class="testproject.model.Person" />
    	<view-state id="createPerson" model="person" view="portletgreet">
    		<transition on="clone" to="clonePerson">
    			<evaluate expression="personService.clone(person)" result="flowScope.pers" />
    		<transition on="greet" to="greetPersonAction" validate="false" />
    		<transition on-exception="java.lang.RuntimeException" to="createPerson" />
    	<action-state id="greetPersonAction">
    		<evaluate expression="personService.greet(person)" result="flowScope.greeting" />
    		<transition to="greetPerson" />
    	<view-state id="greetPerson"  view="portletgreet" >
    			<render fragments="greet" />
    		<transition on="cancel" to="cancel" />
    	<view-state id="clonePerson" view="portletclone">
    		<transition on="cancel" to="cancel" />
    	<end-state id="cancel" view="portletgreet"/>
    refarchgreet.jsp (refarchclone.jsp looks the same):
    <%@ taglib uri="" prefix="tiles"%>
    <portlet:actionURL var="actionUrl">
    	<portlet:param name="execution" value="${flowExecutionKey}" />
    <h1>Tiles Portlet Example</h1>
    		<td><tiles:insertAttribute name="input" /></td>
    		<hr />
    		<td><tiles:insertAttribute name="greet" /></td>

    I really have no idea how to get that thing run.
    Does anybody has a hint?


  • #2
    Can you show the earlier parts of the log output from about where the PortletDispatcherServlet delgates to Web Flow? Your configurations looks ok. Maybe some exception occurs during view rendering that's not visible in the logs? Try turning up the default logging level.


    • #3

      Thx for your reply.
      Log Level is now on DEBUG.

      While deployment of the portlet the following output is produced:
      see attached file: deployment.txt (in "Log")

      While adding the portlet to the page (liferay) the following output is produced:
      see attached file: adding.txt (in "Log")

      While reloading the page/portlet (CTRL+F5) the following output is produced:
      see attached file: reloading.txt (in "Log")

      For me everything looks fine.
      Would be great if you could help me. I could also offer to send you a zip containing the eclipse-maven project, so that you could try reproducing the error on your site.



      • #4
        From what I can see the request processing goes correctly to Tiles:

        15:40:05.851 [http-8080-1] DEBUG o.s.webflow.engine.ViewState - Rendering + [[email protected] view = org.springframework.webflow.mvc.view.FlowAjaxTilesView: n
        ame 'portletgreet'; URL [portletgreet]]
        15:40:05.856 [http-8080-1] DEBUG o.s.w.mvc.view.FlowAjaxTilesView - Added model object 'viewScope' of type [org.springframework.webflow.core.collection.LocalAttribu
        teMap] to request in view with name 'portletgreet'
        15:40:05.857 [http-8080-1] DEBUG o.a.tiles.impl.BasicTilesContainer - Render request recieved for definition 'portletgreet'
        So my guess is that it's something to do with processing inside the Tiles container. You can try debugging. Or use simple JSP rendering to see if it works without Tiles.


        • #5

          Without tiles it works.
          It must have something to do with it.

          Debugging is a problem, means I don't have an idea how I could debug a Portlet within Eclipse. Do you have an idea?


          • #6
            I add the Pluto container as a regular Tomcat instance to my Servers view but you could also start your server with remote debugging options and then attach with the Eclipse debugger to the debugging port.


            • #7
              I got the remote-debugging in Tomcat/Liferay working.

              I debugged through Tiles, especially through (there are all those render(...) methods)

              Unfortunately I do not see anything that goes wrong.

              But I have a suspicion:
              While debugging I saw some used classes like "ServletTilesRequestContext". I saw in the tiles-portlet project that there are special classes like "PortletTilesRequestContext". Might it be that it has something to do with this? "Servlet..." would be for "normal" webapps, "Portlet..." for "portlet" webapps?

              Does anybody have an idea what else I could try?


              • #8
                Originally posted by huof View Post
                But I have a suspicion:
                While debugging I saw some used classes like "ServletTilesRequestContext". I saw in the tiles-portlet project that there are special classes like "PortletTilesRequestContext". Might it be that it has something to do with this? "Servlet..." would be for "normal" webapps, "Portlet..." for "portlet" webapps?
                The ViewRendererServlet you've configured in web.xml serves as a bridge that allows re-using servlet based View classes (see docs).

                Web Flow's PortletMvcView does include on the PortletRequestDispatcher requesting the fixed view "/WEB-INF/servlet/view", which is what the ViewRendererServlet is mapped to. This causes the Portlet container to wrap the Portlet request/response and invoke a regular Servlet. In short Tiles should be unaware of the Portlet environment in this scenario.


                • #9
                  So we can't use the tiles in portlet environemnt?!
                  Any one tried?


                  • #10
                    As per log it is going to BasicTilesContainer.

                    org.apache.tiles.impl.BasicTilesContainer - Render request recieved for definition 'xxx'

                    But the corresponding jsp never called!! I put some System.out in jsp.


                    • #11
                      Hi spsaran,

                      I did exactly the same.
                      So you have the same problem?

                      I am currently very frustrated .
                      I debugged Tiles and I do not find a small hint what may go wrong.



                      • #12
                        Yeah. The problem is in TilesConfigurer which is only ServletAware not PorletAware.

                        I try to create the PortletTilesRequestContext through factory but there is no portlet tiles context. TilesCongurer creates only ServletTilesApplicationContext. I am not sure whether we can extend the TilesConfigurer as a PorletAware and use it. It may lead some other problem.

                        For quick fix i extended FlowAjaxTilesView and used in tilesViewResolver as a view class, but rendering fragments is not working as expected.

                        public class PortletFlowAjaxTilesView extends FlowAjaxTilesView {
                        	protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response)
                        	throws Exception {
                        		ServletUtil.setForceInclude(request, true);
                        		super.renderMergedOutputModel(model, request, response);
                        Fragment is not working because of ajaxSource is missing in render phase!


                        • #13
                          Tiles should not have to be aware of the Portlet environment when running withing Spring Portlet MVC. Please see the documentation on the ViewRendererServlet especially the comments about the reuse of all the existing Servlet-based view types.


                          • #14
                            Since it is ServletAware, the ServletTilesRequestContext is initialized and used and its dispatch is,

                                public void dispatch(String path) throws IOException {
                                    if (response.isCommitted() || ServletUtil.isForceInclude(request)) {
                                    } else {
                            The dispatch method calls forward(path) when its portlet and its return empty content. I have set the forceInclude true in PortletFlowAjaxTilesView and include called. The include is working.

                            Then the issue in fragment rendering also. SpringJavascriptAjaxHandler checks isAjaxRequest based on ajaxSource request parameter. Since portlet is in rendering phase this parameter is not availble and failed to consider as Ajax request!

                            So Spring Webflow + Tiles in Portlet env is not working

                            Please let us know if we missed any configuration or need to do any custom coding to achieve this!

                            Note: I am using Spring 3.0.3 + Webflow 2.1.0 and Tiles 2.1.2 in WebLogic Portal 10.3.2 environment.


                            • #15
                              I did a test by modifying the booking-portlet-mvc sample. TilesView exposes a few standard forward request attributes in case the servlet container doesn't properly do that itself. This is based on the flag exposeForwardAttributes, which is set to true for pre-2.5 servlet container.

                              When TilesView exposes these attributes the forward works ok. So my guess is that the container I'm using Pluto 2.x does not do that itself. You can try to set this flag to true by overriding TilesView.initServletContext(ServletContext).