Why don't you use a SHtml.hidden with a callback? ------------------------------------- Jonathan Meeks<jonathanme...@gmail.com> wrote:
I have a snippet (call it the "file manager" snippet) that creates a list of snippet tags (each called "file deletion" snippets) to create a virtual file listing with a deletion form next to each of the file names. These "file deletion" snippet methods need to somehow know their corresponding file names so that the submit binding can delete the correct file. I accomplished it with something like the code at the bottom of this message. The general solution was to create the "file deletion" snippet tags with a hidden input that contains the file name. The "file deletion" snippet method, in turn, extracts the value out of the NodeSeq. It works but seems inelegant. Is there a preferred method to do this? Any feedback is welcome. Regards, Jonathan def fileManager(xhtml : NodeSeq) : NodeSeq = { <table> { for(file <- fileList(folderName)) yield <tr> <td>{file.getName}</td> <td> <lift:filesystem.deleteFileForm form="POST"> <input type="hidden" name={fileKeyHiddenFieldName} value={file.getName}/> <deleteFile:submit/> </lift:filesystem.deleteFileForm> </td> </tr> } </table> } def extractHiddenInputValue(name: String, xhtml: NodeSeq) : String = { (xhtml \\ "input").filter(_ \ "@type" == "hidden").filter(_ \ "@value" != "").find(_ \ "@name" == name) match { case Some(node) => (node \ "@value").toString case _ => null } } def deleteFileForm(xhtml : NodeSeq) : NodeSeq = { def deleteFile() = { val fileToDelete = extractHiddenInputValue (fileKeyHiddenFieldName, xhtml) ... } bind("deleteFile", xhtml, "submit" -> SHtml.submit ("delete", deleteFile)) } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---