Announcement Announcement Module
Collapse
No announcement yet.
SWF & spring-js problem: popup rendering and Recource Servlet /resources/* mapping Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SWF & spring-js problem: popup rendering and Recource Servlet /resources/* mapping

    In my project, I have several pages controlled by Spring web flow that are integrated with other Spring MVC part of project. On some of this pages I want to display popups. I did some configuration based on, swf documentation pdf, and some springforum posts, but when I want to render popup I get plain jsp page instead of popup. I don't know is this a configuration problem or my misunderstanding of this spring-js with dojo functionality. Any help is appreciated. And here is my configuration and other files:

    web.xml:
    ----------------------------------------
    here I have my servlets: dispatcher, dwr and resource (from swf documentation example)
    Code:
    	<servlet>
    		<servlet-name>dispatcher</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	<servlet>
    		<servlet-name>dwr-invoker</servlet-name>
    		<servlet-class>org.directwebremoting.spring.DwrSpringServlet</servlet-class>
    		<init-param>
    			<param-name>debug</param-name>
    			<param-value>true</param-value>
    		</init-param>
    		<load-on-startup>2</load-on-startup>
    	</servlet>
    	<servlet>
    		<servlet-name>Resource Servlet</servlet-name>
    		<servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
    		<load-on-startup>3</load-on-startup>
    	</servlet>

    and here is mappings
    Code:
    	
            <servlet-mapping>
    		<servlet-name>dispatcher</servlet-name>
    		<url-pattern>*.html</url-pattern>
    	</servlet-mapping>
    	<servlet-mapping>
    		<servlet-name>dwr-invoker</servlet-name>
    		<url-pattern>/dwr/*</url-pattern>
    	</servlet-mapping>
    
    	<servlet-mapping>
    		<servlet-name>Resource Servlet</servlet-name>
    		<url-pattern>/resources/*</url-pattern>
    	</servlet-mapping>
    1st problem) in my project tree I have already directory recources (with css, and js and other stuff). where I enable this mapping my resources are not available. Is there any way to declare other mappings than /resources/* for resources related with spring-js and dojo ?:
    Code:
    <script type="text/javascript" src="<c:url value="/resources/dojo/dojo.js" />"> </script>
    <script type="text/javascript" src="<c:url value="/resources/spring/Spring.js" />"> </script>
    <script type="text/javascript" src="<c:url value="/resources/spring/Spring-Dojo.js" />"> </script
    here is fragment of my swf flow configuration xml file:
    from "selectionSummary" state on "gotoBtDetails" event user goes to
    btDetails state which is popup view:

    "selectionSummary"
    Code:
    	<view-state id="selectionSummary" view="configurator/selection-summary" model="configuratorDto">
    		<on-entry>
                        ...some evaluations...
    		</on-entry>
    		<transition on="gotoBtDetails" to="btDetails"/>
                       ...some other transition...
    	</view-state> 
    
    	<view-state id="btDetails" view="configurator/details-popup" popup="true">
    	<on-entry>
    		<render fragments="detailsFragment" />
    	</on-entry>
    	<transition on="closeDetails" to="employerSelection"/>
           </view-state>
    on selectionSummary page I have this link:
    Code:
    <a href="${flowExecutionUrl}&_eventId=gotoBtDetails">popup link</a>
    the popup jsp file:
    Code:
    <%@ page contentType="text/html; charset=UTF-8" language="java" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html>
    <head>
    	<title>Web</title>
    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    	
    <script type="text/javascript" src="<c:url value="/resources/dojo/dojo.js" />"> </script>
    <script type="text/javascript" src="<c:url value="/resources/spring/Spring.js" />"> </script>
    <script type="text/javascript" src="<c:url value="/resources/spring/Spring-Dojo.js" />"> </script>
    <link type="text/css" rel="stylesheet" href="<c:url value="/resources/dijit/themes/tundra/tundra.css" />" />
    
    </head>
    <body>
    	<div>Some text before div with id (popup)</div>
    	<div id="detailsFragment" class="detailsFragment">
    		Popup page
    	</div>
    </body>
    </html>

    and here is my dispatcher servlet conf file:
    Code:
    	<dwr:configuration/>
    
    	
    	<dwr:controller id="dwrController" debug="true"/>
    	<bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">
    		<property name="flowExecutor" ref="flowExecutor"/>
    	</bean>
     	<bean id="defaultController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
    	
    	
    	<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    		<property name="maxUploadSize" value="5000000" />
    		<property name="maxInMemorySize" value="5000000" />
    	</bean>
    	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
    		<property name="prefix"><value>/WEB-INF/jsp/</value></property>
    		<property name="suffix"><value>.jsp</value></property>
    	</bean>	
    
    
    	<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
    		<property name="sessionFactory" ref="commonSessionFactory" />
    		<property name="flushModeName" value="FLUSH_NEVER" />
    	</bean>
    
    
    	<bean id="dwrHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="order" value="1" />
    		<property name="alwaysUseFullPath" value="true"/>
    		<property name="interceptors">
    			<list>
    				<ref bean="hibernateInterceptor"/>
    			</list>
    		</property>
    		<property name="mappings">
    			<value>
    				/subscription-configurator.html=flowController
    				/engine.js=dwrController
    				/util.js=dwrController
    				/interface.js=dwrController
    				/call/**=dwrController
    				/interface/**=dwrController
    				/dwr/**=dwrController
    			</value>
    		</property>
    	</bean>
    	<bean id="controllerClassNameHandlerMapping" class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
    		<property name="order" value="2" />
    		<property name="interceptors">
    			<list>
    				<ref bean="hibernateInterceptor"/>
    			</list>
    		</property>
    	</bean>
    	<bean id="beanNameUrlHandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
    		<property name="order" value="3" />
    		<property name="detectHandlersInAncestorContexts" value="true"/>
    		<property name="interceptors">
    			<list>
    				<ref bean="hibernateInterceptor"/>
    			</list>
    		</property>
    	</bean>
    	<bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="order" value="4" />
    		<property name="interceptors">
    			<list>
    				<ref bean="hibernateInterceptor"/>
    			</list>
    		</property>
    				<property name="mappings">
    			<value>
    			</value>
    		</property>
    	</bean>
     
    
    	<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    	    <property name="basename" value="classpath:messages_pl"/>
    	    <property name="defaultEncoding" value="UTF-8"/>
    	    <property name="useCodeAsDefaultMessage" value="true" />
    	</bean>
    	
    	
    	<flow:flow-executor id="flowExecutor" flow-registry="flowRegistry" />
    	
    	<flow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows/">
    		<flow:flow-location id="subscription-configurator" path="configurator-flow.xml" />
    	</flow:flow-registry>
    	
    	<flow:flow-builder-services id="flowBuilderServices" view-factory-creator="viewFactoryCreator"/>
    	
    	<bean id="viewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
    		<property name="viewResolvers">
    			<list>
    				<ref bean="viewResolver"/>
    			</list>
    		</property>
    	</bean>
    2nd problem: When i click popup link, plain jsp page appears with text form jsp

    Code:
    Some text before div with id (popup)
    Popup page
    instead of popup, and when I use firebug to look if this popup page resources are available, there is some status message that indicates that this resource is not available.
    >>>"The requested resource (/tp-web/resources/dojo/dojo.js) is not available."<<<
    dojo.js, Spring.js, Spring-Dojo.js. This files are in spring-js.jar file in classpath. Should I extract them to external folder.

    3rd problem (related with 1st): When i enable Resource servlet my resources in "resources" folder in project tree are also unavailable.

    Questions Summary:
    Q1: Where sould be placed dojo.js, Spring.js and Spring-Dojo.js files to be available.
    Q2: If I have "resources" folder in my project tree (/.../src/main/webapp/resources/) and /resources/* mapping in enabled Resource Servlet why resources from this file are unavailable.
    Q3: Is there any step by step example with spring-js usage and configuration ?

    I use in my project Spring 2.5.6 and SWF 2.0.9

    Thanks for any help

  • #2
    If you have a publicly available /resources and a mapping your servlet engine will be confused and either one will have precedence over the other (I guess basically that this renders your servlet mapping useless).

    Simply change your servlet mapping to whatever you like and change the /resources which need to map to the servlet accordingly (the dojo/spring and spring-dojo js files for instance).

    So basically all you need to do is change the servlet mapping from /resources to something else. Remember it is just a servlet the mapping doesn't matter...

    Comment


    • #3
      thanks for this advice, it was very helpful,

      but there is another issue, the popup is displayed after the link was clicked,
      but in the popup, all the popup jsp body is rendered although I pointed in
      configuration and Spring decorator that I want to render only <div> with id="detailsFragment" from my popup jsp
      .
      I tried to solve it, but I failed, maybe I missed something or tried not enough to achieve solution. Anyway thanks for help, thanks very much.

      Servlet mapping looks like this:
      Code:
      	<servlet-mapping>
      		<servlet-name>Resource Servlet</servlet-name>
      		<url-pattern>/swf/*</url-pattern>
      	</servlet-mapping>
      and the <head> of my selection-summary.jsp and the target popup jsp looks now like this:
      Code:
      	<script type="text/javascript" src="<c:url value="/swf/dojo/dojo.js" />"> </script>
      	<script type="text/javascript" src="<c:url value="/swf/spring/Spring.js" />"> </script>
      	<script type="text/javascript" src="<c:url value="/swf/spring/Spring-Dojo.js" />"> </script>
      and the link to the popup page must be decorated with this code
      Code:
      <a id="btDetailsLink" href="${flowExecutionUrl}&_eventId=gotoBtDetails">popup link</a>
      					<script type="text/javascript">
      						Spring.addDecoration(new Spring.AjaxEventDecoration({
      							elementId: 'btDetailsLink',
      							event: "onclick",
      							popup: true,
      							params: {fragments: "detailsFragment"}
      						}));
      					</script>
      and the view state declaration is (not changed):
      Code:
      	<view-state id="btDetails" view="configurator/details-popup" popup="true">
      	<on-entry>
      		<render fragments="detailsFragment" />
      	</on-entry>
      	<transition on="closeDetails" to="employerSelection"/>
             </view-state>
      Last edited by arteq; May 26th, 2010, 10:15 AM.

      Comment


      • #4
        Has anyone have any idea why whole body is rendered instead of div with id="detailsFragment" ??

        Comment


        • #5
          Try putting your render fragments action inside "on-render" tags instead of "on-entry".

          Comment

          Working...
          X