Tips & Tricks - Open FileWalker in a specific directory

This workshop shows you how you can modify the FileWalker so that a specific directory is automatically selected when the page is loaded.


In our example, the path for the FileWalker connection is "c:\documents".

This directory contains subdirectories with different document types (e.g. templates). There is also a folder called "customers" that contains a folder for each customer number. These customer folders contain documents such as contracts, orders, etc.

Appearance in the browser

The customer numbers are listed in a view table here. When a user clicks on the magnifying glass symbol, a view page opens that contains a FileWalker element; our example connection has been selected here. The FileWalker element loads the defined subdirectory. In the following examples, this will be the "contract" folder that contains the different contracts relating to the customer number selected in the table.

Please note:

In example 1, users can navigate back to the root directory of the FileWalker connection and then go to any other customer directory. This provides the users with permissions that may not be appropriate!

In example 2, users cannot navigate back. The subdirectory is set as the new root directory.

Which example should be used is primarily a question of security; i.e. who should have access to the stored files. In both examples, Intrexx does not currently check whether the subdirectory actually exists.

Example 1: Navigate to a subdirectory

The caller sends the parameter "subDir" (request name: "qs_subDir"); this defines the subdirectory of the FileWalker. The value of the parameter can be dynamically assembled in the properties dialog of the table column containing the button, e.g. via Velocity:

#set($customerid = $drRecord.getValue('<GUID table colums>').asString())
#set($path = "customers/" + $customerid + "/contract")

Add the GUID of the table column that contains the customer number to the script. This can be found on the "Expert" tab in the table column properties.

Example 2: Set new root directory

The caller sends a parameter whose value is processed in the RenderingHandler of the page, which contains the FileWalker, and written to the session. The name of the parameter is a free choice; it is "customerid" in our example. Just like in example 1, the parameter is defined in the properties of a button in the view table that contains the customer numbers.

The RenderingHandler on the page with the FileWalker element writes the key "FILEWALKER_DYNPATH_<GUID_FILEWALKERCONTROL>" to the session. The value of this variable is the subdirectory that should be opened. Because the subdirectory was written to the session, this value applies to each call until the value is actively removed from the session.

if (g_parameter.containsParameter("customerid")) 
	def customerid = g_parameter.get("customerid")
	def path = "customers/${customerid}/contract"
	g_session.put("FILEWALKER_DYNPATH_547ABBCCFC94390342DAD464106A1D5748E4A39E", path.toString()) 
} else { g_session.remove("FILEWALKER_DYNPATH_547ABBCCFC94390342DAD464106A1D5748E4A39E") }