Tips & Tricks - Open FileWalker in a specific directory
This article shows how to modify FileWalker so that a specific directory is selected when a page is loaded.
Connection
A FileWalker connection was set for the path "c:\documents" in the "Integration" module. You can find out how to create a connection here.
The "c:\documents" directory contains subfolders for different document types. There is also the "customers" directory, which in turn contains one folder per customer number. Documents such as contracts, orders etc. are stored in these customer folders.
Appearance in the browser
All customer numbers are listed in a view table in the corresponding application. Clicking on the magnifying glass button loads a view page containing a FileWalker element with the previously created FileWalker connection selected in the properties. In our example, the FileWalker element should automatically switch to the "contract" subdirectory belonging to the selected customer number when loading.
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: Navigating to a subdirectory
The caller sends the parameter "subDir" (request name: "qs_subDir"), which determines the subdirectory of the FileWalker. The value of the parameter can be dynamically assembled in the properties dialog of the table column that contains the button, e.g. using velocity:
#set($customerid = $drRecord.getValue('<GUID table colums>').asString())
#set($path = "customers/" + $customerid + "/contract")
$path
Add the GUID of the table column that contains the customer number to the script. The GUID can be determined in the properties of the table column on the "Expert" tab. The view page then automatically evaluates the parameter when loading and loads the corresponding subfolder.
Example 2: Setting a new root directory
The caller sends a parameter whose value is further processed in the RenderingHandler of the page on which the FileWalker is placed and included in the session. The name of the parameter is freely selectable, in our example it is "customerid". 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 includes the key "FILEWALKER_DYNPATH_<GUIDFILEWALKERKONTROLLE>" in 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")
}