Results 1 to 2 of 2

Thread: swf facelets externalRedirect

  1. #1

    Cool swf facelets externalRedirect

    Hey to all!

    I'm trying to get an externalRedirect ro some way or redirecting to a pdf page residing
    at WEB-INF/reports/report2.pdf for example...


    my view state is in:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <flow xmlns="http://www.springframework.org/schema/webflow"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
    
        <secured attributes="ROLE_USER" />
    
        <persistence-context/>
            <var name="hotelReport" class="org.springframework.webflow.samples.jasper.HotelReport" />
            <var name="reportController" class="org.springframework.webflow.samples.jasper.ReportController" />
            <input name="searchCriteria" required="true" />
    
            <on-start>
                <evaluate expression="bookingService.addMsg('now in subflow...')" />
            </on-start>
            <view-state id="hotelReport.view" view="externalRedirect:http://localhost:8080/swf-booking-faces/spring/reports/report.pdf" popup="true">
                <on-entry>
                    <!-- <evaluate expression="reportController.handleSimpleReport(bookingService.findHotels(searchCriteria,externalContext.locale))" result="flashScope.modelAndView" /> -->
                   <evaluate expression="bookingService.makeHotelReport(bookingService.findReportHotels(searchCriteria,externalContext.locale))" />
                    <evaluate expression="bookingService.addMsg('entered view-state displayPdfState')" />
                </on-entry>
                <transition to="report.end"/>
            </view-state>
    
            <end-state id="report.end" />
    
    </flow>
    I've tried everything to get my view to get simply handled/resolved to this path...

    Problem is that I'm using facelets and my comfiguration just maps/resolves to:

    http://localhost:8080/swf-booking-fa...s/report.xhtml as per the UrlBasedViewResolver

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
    
    	<!-- Maps request paths to flows in the flowRegistry; e.g. a path of /hotels/booking looks for a flow with id "hotels/booking" -->
    	<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
    		<property name="flowRegistry" ref="flowRegistry" />
    		<property name="defaultHandler">
    			<!-- If no flow match, map path to a view to render; e.g. the "/intro" path would map to the view named "intro" -->	
    			<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
    		</property>
    	</bean>
    
    	<!-- Maps logical view names to Facelet templates in /WEB-INF (e.g. 'search' to '/WEB-INF/search.xhtml' -->
    	<bean id="faceletsViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    
    		<property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
    		<property name="prefix" value="/WEB-INF/" />
    		<property name="suffix" value=".xhtml" />
                    <property name="order" value="2" />
    	</bean>
    
            <bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
    		<property name="viewResolvers">
                       <list>
                           <ref bean="jasperViewResolver" />                       
                           <ref bean="faceletsViewResolver" />
                       </list>
                     </property>
           </bean>
    
        <!-- the ResourceBundleViewResolver -->
        <bean id="jasperViewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
          <property name="basename" value="views"/>
          <property name="order" value="1" />
        </bean>
     
                    
    
    	<!-- Dispatches requests mapped to org.springframework.web.servlet.mvc.Controller implementations -->
    	<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
    
    	<!-- Dispatches requests mapped to flows to FlowHandler implementations -->
    	<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
    		<property name="flowExecutor" ref="flowExecutor" />
    	</bean>
    
    			
    </beans>
    what changes could i make to force the redirect to bypass the UrlBasedViewResolver??

    I've tried many things even an external servlet but nothing works?

    Any help appreciated,

    cheers!

  2. #2

    Lightbulb swf-booking-faces jasper reports

    I guess I should elaborate on the situation.

    I'm taking the swf-booking-faces sample bundled in the SWF distribution ver2.0.5 (a recent distr)
    and getting the reviewHotels.xhtml to have a sf:commandLink that will print the Hotels searchResult (as a popup) using
    jasperreports.

    OK so I can produce the report.pdf to a folder on the classpath, no problem. But how could you open the view using webflow?
    (I've tried many classpath locations, settled on
    Code:
    C:\NetBeansProjects\swf-booking-faces_sept18\src\main\webapp\reports\report.pdf
    since that will open with
    Code:
    http://localhost:8084/swf-booking-faces/reports/report2.pdf
    )

    The only way I can open it is with:

    Code:
    <view-state id="report2.view" view="externalRedirect:/reports/report2.pdf">
    but then I get the first cached version produced when the server started and the <view popup=true doesn't work
    with externalRedirects.

    It seems the only way to have the report work is with
    Code:
    <a href="simpleReport.pdf" target="_blank">Printable list</a>
    that will only compile a hardcoded data ( via the JasperReportsPdfView class )with no interaction with current view (ie: you couldn't send the search criteria to the query).

    There must be a way to produce the report in a flow that will have access to flow vars. If you separate the report to a controller with req/resp it won't interact with the flow and xhtml components,... leaves you cold!

    I have managed to popup the report but it creates parse errors since it's a pdf file...

    What to do?

    Has anyone been able to open pdf jasperreports using the swf-booking-faces sample yet?

    Regards,

    John

    P.S. tried everything, separate servlet etc, gets swallowed up/busted by the framework.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •