Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve locating/loading of flow resources [SWF-1683] #861

Open
spring-operator opened this issue Feb 26, 2016 · 1 comment
Open

Improve locating/loading of flow resources [SWF-1683] #861

spring-operator opened this issue Feb 26, 2016 · 1 comment

Comments

@spring-operator
Copy link
Contributor

Johannes Grimm opened SWF-1683 and commented

In a scenario where I have two flows (abstract-flow and example-flow) and example-flow inherits from abstract-flow the resources defined in of abstract-flow can not be resolved if it is located in a different folder than example-flow.

Let's make the example more explicit. We have our files arranged like in the following tree:

\---webapp
    \---WEB-INF
        \---flows
            +---abstract-flow
                +---abstract-flow.xml
                +---abstract-flow-beans.xml
                \---abstract-view.xhtml
            \---example-flow
                +---example-flow.xml
                \---example-view.xhtml

And the files have the following content:

<?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"
    abstract="true">

    <view-state id="abstract-view" />
    
    <global-transitions>
        <transition on="abstract-view" to="abstract-view" />
    </global-transitions>
    
    <bean-import resource="abstract-flow-beans.xml" />
</flow>
<beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/aop
                           http://www.springframework.org/schema/aop/spring-aop.xsd
                           http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/util 
                           http://www.springframework.org/schema/util/spring-util-2.5.xsd">

    <util:list id="abstractList">
        <value>One</value>
        <value>Two</value>
        <value>Three</value>
    </util:list>
    
</beans>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
    <title>abstract-flow: abstract-view</title>
</h:head>
<h:body>
    <h:form>
        <h1>abstract-flow: abstract-view</h1>
    </h:form>
</h:body>
</html>
<?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"
    parent="abstract-flow"
    start-state="example-view">

    <view-state id="example-view" />
    
</flow>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
    <title>example-flow: example-view</title>
</h:head>
<h:body>
    <h:form>
        <h1>example-flow: example-view</h1>
        
        <div>
            <strong>abstractList: </strong>#{abstractList}
        </div>
        
        <h:commandButton value="Show abstract-view" action="abstract-view" />
    </h:form>
</h:body>
</html>

If one tries to access the example-flow of this configuration an exception will be raised indicating that some resources were not found. (I know this behavior is documented but wouldn't it be nice to have this working?)

The modifications in [^patch.diff] ensure that the resources will be loaded relative to the defining flow. A complete and working example is included as [^resource-location.zip]. This project already contains the patched webflow classes.


Affects: 2.4.2

Attachments:

@spring-operator
Copy link
Contributor Author

Rossen Stoyanchev commented

Seems reasonable.

@rstoyanchev rstoyanchev modified the milestones: 2.5 Backlog, General Backlog Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants