We pretty much have everything in place to set up our Delete Files option. But now that we’re sure Mozilla’s itemset is working, we’re going to use a select control with itemset rather than the approach we took in Directory List Xforms and PHP pt. 1 where we listed the files in our directory using xf:input (with a boolean type, which resulted in the same effect as a select element).
Now, however, it should all be much simpler with itemset.
Here’s another look at the xml file structure
<fileManager> <viewFile>Testing</viewFile> <deleteFiles/> <fileList type="multi"> <file text="fakeEmtpyaad232" full="./Forms/fakeEmtpyaad232.xhtml" select="false"/> <file text="fakeEmtye" full="./Forms/fakeEmtye.xhtml" select="false"/> <file text="fakeEmtyef" full="./Forms/fakeEmtyef.xhtml" select="false"/> <file text="xfakeEmptyxxxxxxx" full="./Forms/xfakeEmptyxxxxxxx.xhtml" select="false"/> </fileList> </fileManager>
Here’s an image:
We’ll also have a handy little second chance button. Like so:
What’s nice about the second chance button is that it’s all xforms and client-side; lightning fast, no scripting. To know how to do this go to To submit or not?
Now for the “delete files” code, here’s the core of it:
<xf:select ref="deleteFiles" appearance="full" >
<h:span style="color:maroon; font-size:125%;">
<xf:label >Select the forms to delete: </xf:label>
</h:span>
<xf:itemset nodeset="//file">
<xf:value ref="@full" />
<xf:label ref="@text" />
</xf:itemset>
</xf:select>
And that’s pretty much it.
Notice one thing we did NOT add and that is an “All Files Selected” option. That would be a pretty dangerous option for our poor user who may have been up all night making last minute final exams or what have you .. and then, *poof* –so we’ll just let our user select them one at a time even if there are hundreds of them.
One thing we could do, however, if you suspect your user will be working with a lot of files, is to set the xf:select appearance to appearance=”compact” rather than “full.” In this mode, the user will be allowed to use the control and shift keys just like in a regular directory to select several files at once.
You’ll need to move your label around, of course. See below:
next, we’ll see what we need to do with the selected files when our PHP file recieves the submitted xml data.
addendum 09/12/07: I’ve actually decided to go with “compact” since the current rendering on a pc tends to act like a regular file directory (using select and ctl keys for multi-selections). In my application, I lengthened the menu box to height:45ex; so that 20 or so files will show at a time.



[...] delete+= files Previously we set up our Xforms to send some file names to our php file (see Directory List: DeleteĀ files [...]
Pingback by Directory list: process delete files « Clarkepeters’s Weblog — September 12, 2007 @ 10:51 am