0

Is it possible to place the JSF flow folder somewhere else than the root of the application like... in WEB-INF folder? Or somehow to forbid direct access to the pages in it?

Pavel
  • 1,278
  • 2
  • 17
  • 34

2 Answers2

1

I solved this one myself.

A JSF flow definition can be done in 2 ways:

  • with configuration file: flowname-flow.xml
  • with configuration class: flowname.java

The first one can only define a flow-name, with the location defaulting to the root folder.

The second can define a location deeper in your folder structure.

Configuration file example: testflow.flow.xml

Only the id="testFlow" can be added to the definition, and not the path. This defaults to testFlow/testFlow.xhtml for the first page.

<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
    <flow-definition id="testFlow">
        <flow-return id="returnFromTestFlow">
            <from-outcome>#{testFlow.returnValue}</from-outcome>
        </flow-return>
    </flow-definition>
</faces-config>

Configuration class example: TestFlow.java

Add the fully qualified path to the view node within this flow.

public class TestFlow implements Serializable {

    private static final long serialVersionUID = 1L;

    @Produces
    @FlowDefinition
    public Flow defineFlow(@FlowBuilderParameter FlowBuilder flowBuilder) {

        String flowId = "testFlow";
        flowBuilder.id("", flowId);
        flowBuilder.viewNode(flowId, 
                "/other/location/flow/" + flowId + ".xhtml").
                markAsStartNode();
        flowBuilder.viewNode("testFlow2", "/other/location/flow/testFlow2.xhtml");
        flowBuilder.viewNode("testFlow3", "/other/location/flow/testFlow3.xhtml");
        ...

That's all folks!

Dimitri Dewaele
  • 10,311
  • 21
  • 80
  • 127
0

You can always create folders inside the root folder to store your pages. To restrict client access, for example, you can put all admin-related pages into a folder called admin. Then, you can restrict user access by using the account type after they've logged in. This can be done easily using a Servlet. One thing to note is that you should never put normal pages and template clients inside the WEB-INF folder.

For your information:

Community
  • 1
  • 1
Mr.J4mes
  • 9,168
  • 9
  • 48
  • 90
  • @VasilLukach: Read carefully :). I'm talking about template clients. Of course, master template files can be put inside `WEB-INF`. – Mr.J4mes May 01 '14 at 18:32
  • @Mr4.J4mes I am talking about the new flow pages. There is a way to place them in a jar file, but I cant figure how to do it. – Pavel May 07 '14 at 00:20