RE: form control to select a folder

Iņaki,
 
We discussed this issue in a recent Forms Working Group meeting, and I'm responding based on the group's discussion. [1]
 
The upload control is patterned after the HTML <input type="file"> element, which provides opaque access to a local filesystem file and the final component of the file name.  
The XForms upload control is designed to access generic resources on the client and submit their contents to the server.  While these resources may be files, they could be any resource that is specified by the client user agent and which can be serialized into the submission.  The XForms Recommendation cites captured images (such as from a camera or scanner) and captured audio.  The XForms upload control optionally provides a media type (MIME type) and a filename.  Although XForms does not specify the definition of a filename, most implementations follow the HTML4 practice of including only the final filename component (i.e., without directory structure), for security reasons. Note that in neither HTML4 nor in XForms is it possible for the server side to obtain a full pathname and access that resource directly.
 
Your use case doesn't not involve the upload of any client-side resource content, so it seems that the upload control is not the correct abstract control to use.  Furthermore, it is also difficult to see how, in the general case, a server that receives submitted data including a local filename (but no local contents) could access the specified file.
 
In your application, you describe client extensions done in Java which use a browser permission model to grant permission for the Java code to access the local file; however, this requires extensions outside XForms and outside the scope of most browser interactions, due to security concerns prevalent in desktop browsers.
 
Despite the fact that the upload control as implemented in the Mozilla Firefox extension uses a file selection dialog box, the control your use case calls for seems to be a variant of input, rather than a variant of upload.  The input control is responsible for getting user input for atomic values, and is also responsible for making use of user agent facilities to capture that input.  For example, when bound to an xsd:date type, the input control should offer some sort of date chooser.  An example use case might be a data-gathering application that wishes to record the filenames of configuration files on a user's system, but not necessarily provide access to those files.
 
Unfortunately, at this point, the use case for a filename chooser does not seem to be general enough to warrant action by the Forms Working Group either for the changes to upload you request nor for the definition of a "filename" Schema simpleType in the XForms namespace.
 
However, since your use case already involves implementation-specific details such as Java applets and the Mozilla security model, we recommend that you experiment with the Mozilla XBL binding feature.  You can define an XML Schema simpleType corresponding to a filename, and then use XBL to associate the "file chooser" behavior with input controls bound to this type.
 
You may want to discuss this experimentation on the Mozilla XForms implementation discussion list, whose archive is available at https://lists.mozilla.org/listinfo/dev-tech-xforms <https://lists.mozilla.org/listinfo/dev-tech-xforms> 
 
Please do keep www-forms informed if you have some results of experiments with XBL this use case, and let us know if this explanation is unclear, or if you think we've made a mistake.
 
Leigh.
 
[1] http://lists.w3.org/Archives/Public/public-forms/2007May/att-0058/20070516-2.html#topic7

________________________________

From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On Behalf Of Iņaki Salinas Bueno
Sent: Tuesday, May 08, 2007 3:01 PM
To: www-forms
Subject: form control to select a folder


Hi all,

I want to suggest include the option of select a folder using upload form control (or another form control).

My scenario is:
- The user had a java.policy defined. This policy allows applets signed by X to write/read in a particular folder (choosed by the user). 
- The signing applet (signed by X) must know this folder to be able to store the documents in the user's PC.
- In the XForms+applet application, the user should enter the destination folder with other critical information and then call the applet sending it this parameters. 

I have to use the input control and do copy&paste of the folder's path because the upload control isn't able to select a folder. I understand a folder as an URI, so I suppose a folder is included in the xsd:anyURI type definition, and the upload control is the manager of this type... reading the spec I don't see anything wrong in including folder selection in the upload control (well, avoiding filename, and maybe mediatype and size). 

Aaron Reed explained me some problems on knowing if the user wants to select a folder or wants to select a file. I don't know how to solve this problem.

My use case:

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> 

<html    xmlns="http://www.w3.org/1999/xhtml"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
        
<head>

    <title>Test - Select a folder as input</title>
    
    <script language="javascript">
        <![CDATA[
        function sign() {
            //get the instance 
            var model = document.getElementById("model");
            var instance = model.getInstanceDocument("data");
            
            //get parameter
            var keystore = instance.getElementsByTagName("keystore");
            var password = instance.getElementsByTagName("password");
            var folder = instance.getElementsByTagName("folder");
            
            //call the applet
            document.applets.item("theapplet").sign(keystore[0].firstChild.nodeValue, password[0].firstChild.nodeValue, folder[0].firstChild.nodeValue);
        }
        ]]> 
    </script>
    
    <xforms:model id="model">
    
        <xforms:instance id="data" xmlns="">
            <data>
                <keystore filename="" mediatype="" size="" /> 
                <password />
                <folder filename="" mediatype="" size="" />
            </data>
        </xforms:instance>
        <xforms:bind nodeset="instance('data')/keystore" type="xsd:anyURI"/> 
        <xforms:bind nodeset="instance('data')/password" id="password" type="xsd:string"/>
        <xforms:bind nodeset="instance('data')/folder" type="xsd:anyURI"/> 
    </xforms:model>
    
</head>

<body>

    <h1>Signing test</h1>
    
    <h2>Key Access</h2>
    <p>
        <xforms:upload ref="instance('data')/keystore"> 
            <xforms:label>Select your KeyStore</xforms:label>
            <xforms:filename ref="@filename"/>
            <xforms:mediatype ref="@mediatype"/>
            <xforms:size ref="@size"/> 
        </xforms:upload>
        <xforms:secret bind="password"><xforms:label>Password</xforms:label></xforms:secret>
    </p>
    <h2>Destination folder</h2> 
    <p>
        <xforms:upload ref="instance('data')/folder">
            <xforms:label>Folder</xforms:label>
            <xforms:filename ref="@filename"/> 
            <xforms:mediatype ref="@mediatype"/>
            <xforms:size ref="@size"/>
        </xforms:upload>
    </p>    
    
    <p>
        <xforms:trigger> 
            <xforms:label>Sign</xforms:label>
            <xforms:action ev:event="DOMActivate">
                <xforms:load resource="javascript:sign()"/>
            </xforms:action> 
        </xforms:trigger>
    </p>
    
    
    <!--* APPLET FIRMA *-->
    <applet    code="signing.Sign.class"
            archive="sSigning.jar"
            type="application/x-java-applet" 
            width="200" height="200" id="theapplet">
        Signing no se ha podido cargar
    </applet>
    <!-- -->
    
</body>

</html> 


Regards

Iņaki

Received on Friday, 18 May 2007 18:08:02 UTC