Directory-picker for form input using Java servlets or JavaScript -
i'd create directory-picker form input element, allow users select network directory selected , passed target server process. idea users browse network share, visible user's machine , web server, , select folder request processed server application. i'd function <input type="file">
tag would, allowing folder selection instead of files.
i have read html file-picker input not support behavior, might possible using java servlets or javascript, though have found no code demonstrates this. possible create form element this? using spring mvc 3, , intranet application, security not issue. new java-based web development, don't know start here.
you have interface users move in , out of directories
the servlet or spring-mvc controller part of pretty simple (excluding exceptions , such).
@requestmapping(value = "/network/*") @responsebody // serialize json since using javascript public list<string> getdirectory(@requestparam("direction") string direction, httpservletrequest request) { list<string> paths = new linkedlist<string>(); string path = request.getrequesturi(); path = path.substring(path.indexof("/network") + 8); // gets after /network if ("up".equals(direction)) { // want go 1 folder file parent = new file(path).getparentfile(); // parent, might return null have check paths.addall(arrays.aslist(parent.list())); } else if ("into".equals(direction)) { file directory = new file(path); // files in current directory paths.addall(arrays.aslist(directory.list())); } return paths; }
you make ajax requests to
http://www.your-intranet.com/network/var/this/path/wanted?direction=into
to retrieve json list of files , folders inside it. or
http://www.your-intranet.com/network/var/this/path/wanted?direction=up
equivalent to
http://www.your-intranet.com/network/var/this/path?direction=into
depending on want path extraction logic (probably on server since knows if right or not).
the ui part of little harder , won't it, have parse json , decide if want show folder icon or file icon different buttons different operations.
you have play around paths depending on linux or windows os.
Comments
Post a Comment