Search code examples
primefacesjsf-2wildfly-10

JSF / Primefaces Link to Filesystem


I have a WebApplication, where I have to provide direct access to a mounted network drive on the client side (e.g. \\server\zentrale mapped to drive Z:\).

I tried following, but nothing works:

<a target="_blank" href="file:///server/zentrale/username/data">user files</a>
<h:outputlink target="_blank" value="file:///server/zentrale/username/data">user files</a>

<a target="_blank" href="file:///Z:/username/data">user files</a>
<h:outputlink target="_blank" value="file:///Z:/username/data">user files</a>

I also added <disable-cross-context>false</disable-cross-context> in my jboss-web.xml - without success.

@BalusC mentioned in JSF 2 and a link to file system to create a new webapp context. So, how can I do this using WildFly 10 and Primefaces 6.1 ?

In an older version of our WebApplication we used the IE View plugin for Firefox, but this was last updated in 2013! Because we have to support other browser like Chrome and IE, we don't want to be dependent on some browser plugins!


Solution

  • In https://developer.jboss.org/thread/227893 I found a hint, how to get access to the local filesystem on the server side.

    standalone.xml

    <subsystem xmlns="urn:jboss:domain:undertow:3.0">
        <buffer-cache name="default"/>
        <server name="default-server">
            <http-listener name="default" socket-binding="http" redirect-socket="https"/>
                <host name="default-host" alias="localhost">
                    <location name="/" handler="welcome-content"/>
                    <location name="documents" handler="document-handler"/>
                    <filter-ref name="server-header"/>
                    <filter-ref name="x-powered-by-header"/>
                </host>
        </server>
        <handlers>
            <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
            <file name="document-handler" directory-listing="true" path="\\server\Zentrale\docments"/>
        </handlers>
    </subsystem>
    

    To achieve this using jboss-cli.sh use the following commands:

    /subsystem=undertow/server=default-server/host=default-host/location=documents:add(handler=document-handler)
    /subsystem=undertow/configuration=handler/file=document-handler:add(path=\\\\server\\Zentrale\\documents, directory-listing=true)
    

    A click on each link in page.xhtml opens a new tab in the browser where I can navigate in the server's file system - even on shared folders!

    page.xhtml

    <a href="/documents/projects/project_4711/" target="_blank">Project 4711</a>
    <h:outputLink value="/documents/projects/project_4711/" target="_blank">Project 4711</h:outputLink>
    

    This is the solution for my problem, but yes - it does not allow me to navigate on the clients local filesystem!