|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Retrieve list all files stored in the same folderHi, I'd like to store lots of documents in different places in my file manager and let page creators (webmasters) to choose one directory and the template will be responsible for displaying all the files stored in that directory. First question: Is it possible to instanciate the file chooser to choose not a file but a folder? if I can't select a folder, I will ask page creator to select one file from the directory we want to list all files and the processing will do the job. By searching this way, I found that JahiaFile has a getFolderId() method but I can't figure what I can do with the folder id ? Second question: Is there an API to exploid the folder id retrieve from a JahiaFile ? Third question: How to get the list of file from one folder ?? I saw the jahiaWebdavBaseService but I'm not sure at all that I'm on the right way? Thank you very much for your replies, Benoit Pironet I'm using Jahia 5.0.3 _______________________________________________ dev_list mailing list dev_list@... http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list |
|
|
Re: Retrieve list all files stored in the same folderHi,
I assume, you are using Jahia 5.0 SP3. 1) You can create the "WebDAV folder selector" in your page using the following code: <input type="text" name="myFolder" id="myFolder" value=""/> <a href="#select" onclick="javascript:{var pathSelector = window.open('<%= request.getContextPath() %>/jsp/jahia/engines/webdav/webdavrepository.jsp?display=directories_Only&htmlElementId=myFolder', 'pathSelector_<%= request.getSession().getId()%>', 'resizable,height=800,width=600'); pathSelector.focus(); return false;}"> Select folder </a> It contains an input field (with ID) and a link to the folder selector, where you pass the ID of the input element to store the selected folder path. The only thing, your will need to remove the '/jahia/webdav' from the URL. 2) To get the folder path for the selected file (Jahia field of type 'File') you can use the following code: I am using mainContent container as an example (see our corporate_portal_templates_v2/common/main_content.jsp). The field name is 'image'. <%@ page import="org.jahia.services.webdav.JahiaWebdavBaseService, org.jahia.services.webdav.DAVFileAccess, org.jahia.data.beans.RequestBean, org.jahia.params.ProcessingContext, org.jahia.data.files.JahiaFile, org.apache.commons.io.FilenameUtils" %> <content:containerList name='<%="mainContentList" + id%>' id="mainContentList"> ... <content:container id="mainContent"> ... <logic:present name="mainContent" property="field(image)"> <bean:define id="image" name="mainContent" property="field(image).object"/> <logic:present name="image"> <bean:define id="filePath" name="image" property="realName"/> <% String folderPath = FilenameUtils.getFullPathNoEndSeparator((String) pageContext.getAttribute("filePath")); if (folderPath != null && folderPath.length() != 0) { ProcessingContext jParams = ((RequestBean) request.getAttribute("currentRequest")).getParamBean(); DAVFileAccess folderItem = JahiaWebdavBaseService.getInstance().getDAVFileAccess(jParams, folderPath); %> Here is the folder path of the selected file: <%= folderItem.getPath() %> <% } %> </logic:present> </logic:present> ... </content:container> </content:containerList> 3) You can get a list of files (and also sub folders) in your template JSP using the DAVFileAccess API (http://www.jahia.org/javadoc-dev_5/org/jahia/services/webdav/DAVFileAccess.html) in the following way: <%@ page import="org.jahia.services.webdav.JahiaWebdavBaseService,org.jahia.services.webdav.DAVFileAccess" %> <h3>Content of the /shared/myfolder</h3> <ul> <% DAVFileAccess myFolder = JahiaWebdavBaseService.getInstance().getDAVFileAccess(jParams, "/shared/myfolder"); List children = myFolder.getChildren(); for (Iterator it = children.iterator(); it.hasNext();) { DAVFileAccess item = (DAVFileAccess) it.next(); boolean isFolder = item.isCollection(); %><li><a href="<%= request.getContextPath() %>/webdav<%= item.getPath() %>" target="_blank"><%= item.getName() %>[<%= isFolder ? "folder" : "file" %>]</a></li><% } %> </ul> Kind regards Sergiy PIRONET Benoît schrieb: > Hi, > > I'd like to store lots of documents in different places in my file manager and let page creators (webmasters) to choose one directory and the template will be responsible for displaying all the files stored in that directory. > > First question: > Is it possible to instanciate the file chooser to choose not a file but a folder? > if I can't select a folder, I will ask page creator to select one file from the directory we want to list all files and the processing will do the job. > By searching this way, I found that JahiaFile has a getFolderId() method but I can't figure what I can do with the folder id ? > > Second question: > Is there an API to exploid the folder id retrieve from a JahiaFile ? > > > > Third question: How to get the list of file from one folder ?? > I saw the jahiaWebdavBaseService but I'm not sure at all that I'm on the right way? > > > Thank you very much for your replies, > > > Benoit Pironet > > > > I'm using Jahia 5.0.3 > _______________________________________________ > dev_list mailing list > dev_list@... > http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list > _______________________________________________ dev_list mailing list dev_list@... http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list |
|
|
Re: Retrieve list all files stored in the same folderAlso please note that the DAVFileAccess API will change and be replaced by a new one in the next major release of Jahia. We will be introducing more generic APIs on top of multiple file repositories. This change will not happen in the service packs (SP4, etc), but only in the next major release. Regards, Serge Huber. Sergiy Shyrkov a écrit : > Hi, > > I assume, you are using Jahia 5.0 SP3. > > 1) You can create the "WebDAV folder selector" in your page using the > following code: > > <input type="text" name="myFolder" id="myFolder" value=""/> > <a href="#select" > onclick="javascript:{var pathSelector = window.open('<%= > request.getContextPath() > %>/jsp/jahia/engines/webdav/webdavrepository.jsp?display=directories_Only&htmlElementId=myFolder', > 'pathSelector_<%= request.getSession().getId()%>', > 'resizable,height=800,width=600'); pathSelector.focus(); return false;}"> > Select folder > </a> > > It contains an input field (with ID) and a link to the folder selector, > where you pass the ID of the input element to store the selected folder > path. The only thing, your will need to remove the '/jahia/webdav' from > the URL. > > 2) To get the folder path for the selected file (Jahia field of type > 'File') you can use the following code: > I am using mainContent container as an example (see our > corporate_portal_templates_v2/common/main_content.jsp). > The field name is 'image'. > > <%@ page import="org.jahia.services.webdav.JahiaWebdavBaseService, > org.jahia.services.webdav.DAVFileAccess, > org.jahia.data.beans.RequestBean, > org.jahia.params.ProcessingContext, > org.jahia.data.files.JahiaFile, > org.apache.commons.io.FilenameUtils" %> > > <content:containerList name='<%="mainContentList" + id%>' > id="mainContentList"> > ... > <content:container id="mainContent"> > ... > <logic:present name="mainContent" property="field(image)"> > <bean:define id="image" name="mainContent" > property="field(image).object"/> > <logic:present name="image"> > <bean:define id="filePath" name="image" property="realName"/> > <% > String folderPath = > FilenameUtils.getFullPathNoEndSeparator((String) > pageContext.getAttribute("filePath")); > if (folderPath != null && folderPath.length() != 0) { > ProcessingContext jParams = ((RequestBean) > request.getAttribute("currentRequest")).getParamBean(); > DAVFileAccess folderItem = > JahiaWebdavBaseService.getInstance().getDAVFileAccess(jParams, folderPath); > %> > > Here is the folder path of the selected file: <%= > folderItem.getPath() %> > > <% > } > %> > </logic:present> > </logic:present> > ... > </content:container> > </content:containerList> > > > 3) You can get a list of files (and also sub folders) in your template > JSP using the DAVFileAccess API > (http://www.jahia.org/javadoc-dev_5/org/jahia/services/webdav/DAVFileAccess.html) > in the following way: > > <%@ page > import="org.jahia.services.webdav.JahiaWebdavBaseService,org.jahia.services.webdav.DAVFileAccess" > %> > <h3>Content of the /shared/myfolder</h3> > <ul> > <% > DAVFileAccess myFolder = > JahiaWebdavBaseService.getInstance().getDAVFileAccess(jParams, > "/shared/myfolder"); > List children = myFolder.getChildren(); > for (Iterator it = children.iterator(); it.hasNext();) { > DAVFileAccess item = (DAVFileAccess) it.next(); > boolean isFolder = item.isCollection(); > %><li><a href="<%= request.getContextPath() %>/webdav<%= > item.getPath() %>" target="_blank"><%= item.getName() %>[<%= isFolder ? > "folder" : "file" %>]</a></li><% > } > %> > </ul> > > > Kind regards > Sergiy > > PIRONET Benoît schrieb: > >> Hi, >> >> I'd like to store lots of documents in different places in my file manager and let page creators (webmasters) to choose one directory and the template will be responsible for displaying all the files stored in that directory. >> >> First question: >> Is it possible to instanciate the file chooser to choose not a file but a folder? >> if I can't select a folder, I will ask page creator to select one file from the directory we want to list all files and the processing will do the job. >> By searching this way, I found that JahiaFile has a getFolderId() method but I can't figure what I can do with the folder id ? >> >> Second question: >> Is there an API to exploid the folder id retrieve from a JahiaFile ? >> >> >> >> Third question: How to get the list of file from one folder ?? >> I saw the jahiaWebdavBaseService but I'm not sure at all that I'm on the right way? >> >> >> Thank you very much for your replies, >> >> >> Benoit Pironet >> >> >> >> I'm using Jahia 5.0.3 >> _______________________________________________ >> dev_list mailing list >> dev_list@... >> http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list >> >> > > _______________________________________________ > dev_list mailing list > dev_list@... > http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list > > _______________________________________________ dev_list mailing list dev_list@... http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list |
|
|
Re: Retrieve list all files stored in the same folderHi all,
Thank you for the information. Now, my main problem is to index the file that are in the folder as content of the page where the folder is selected. Are there some ways to do so and what is the best way ? Regards, Benoit Pironet -----Original Message----- From: dev_list-bounces@... on behalf of Serge Huber Sent: Mon 23/06/2008 08:14 To: Here you can discuss and comment current and future developments of Jahia Subject: Re: [dev_list] Retrieve list all files stored in the same folder Also please note that the DAVFileAccess API will change and be replaced by a new one in the next major release of Jahia. We will be introducing more generic APIs on top of multiple file repositories. This change will not happen in the service packs (SP4, etc), but only in the next major release. Regards, Serge Huber. Sergiy Shyrkov a écrit : > Hi, > > I assume, you are using Jahia 5.0 SP3. > > 1) You can create the "WebDAV folder selector" in your page using the > following code: > > <input type="text" name="myFolder" id="myFolder" value=""/> > <a href="#select" > onclick="javascript:{var pathSelector = window.open('<%= > request.getContextPath() > %>/jsp/jahia/engines/webdav/webdavrepository.jsp?display=directories_Only&htmlElementId=myFolder', > 'pathSelector_<%= request.getSession().getId()%>', > 'resizable,height=800,width=600'); pathSelector.focus(); return false;}"> > Select folder > </a> > > It contains an input field (with ID) and a link to the folder selector, > where you pass the ID of the input element to store the selected folder > path. The only thing, your will need to remove the '/jahia/webdav' from > the URL. > > 2) To get the folder path for the selected file (Jahia field of type > 'File') you can use the following code: > I am using mainContent container as an example (see our > corporate_portal_templates_v2/common/main_content.jsp). > The field name is 'image'. > > <%@ page import="org.jahia.services.webdav.JahiaWebdavBaseService, > org.jahia.services.webdav.DAVFileAccess, > org.jahia.data.beans.RequestBean, > org.jahia.params.ProcessingContext, > org.jahia.data.files.JahiaFile, > org.apache.commons.io.FilenameUtils" %> > > <content:containerList name='<%="mainContentList" + id%>' > id="mainContentList"> > ... > <content:container id="mainContent"> > ... > <logic:present name="mainContent" property="field(image)"> > <bean:define id="image" name="mainContent" > property="field(image).object"/> > <logic:present name="image"> > <bean:define id="filePath" name="image" property="realName"/> > <% > String folderPath = > FilenameUtils.getFullPathNoEndSeparator((String) > pageContext.getAttribute("filePath")); > if (folderPath != null && folderPath.length() != 0) { > ProcessingContext jParams = ((RequestBean) > request.getAttribute("currentRequest")).getParamBean(); > DAVFileAccess folderItem = > JahiaWebdavBaseService.getInstance().getDAVFileAccess(jParams, folderPath); > %> > > Here is the folder path of the selected file: <%= > folderItem.getPath() %> > > <% > } > %> > </logic:present> > </logic:present> > ... > </content:container> > </content:containerList> > > > 3) You can get a list of files (and also sub folders) in your template > JSP using the DAVFileAccess API > (http://www.jahia.org/javadoc-dev_5/org/jahia/services/webdav/DAVFileAccess.html) > in the following way: > > <%@ page > import="org.jahia.services.webdav.JahiaWebdavBaseService,org.jahia.services.webdav.DAVFileAccess" > %> > <h3>Content of the /shared/myfolder</h3> > <ul> > <% > DAVFileAccess myFolder = > JahiaWebdavBaseService.getInstance().getDAVFileAccess(jParams, > "/shared/myfolder"); > List children = myFolder.getChildren(); > for (Iterator it = children.iterator(); it.hasNext();) { > DAVFileAccess item = (DAVFileAccess) it.next(); > boolean isFolder = item.isCollection(); > %><li><a href="<%= request.getContextPath() %>/webdav<%= > item.getPath() %>" target="_blank"><%= item.getName() %>[<%= isFolder ? > "folder" : "file" %>]</a></li><% > } > %> > </ul> > > > Kind regards > Sergiy > > PIRONET Benoît schrieb: > >> Hi, >> >> I'd like to store lots of documents in different places in my file manager and let page creators (webmasters) to choose one directory and the template will be responsible for displaying all the files stored in that directory. >> >> First question: >> Is it possible to instanciate the file chooser to choose not a file but a folder? >> if I can't select a folder, I will ask page creator to select one file from the directory we want to list all files and the processing will do the job. >> By searching this way, I found that JahiaFile has a getFolderId() method but I can't figure what I can do with the folder id ? >> >> Second question: >> Is there an API to exploid the folder id retrieve from a JahiaFile ? >> >> >> >> Third question: How to get the list of file from one folder ?? >> I saw the jahiaWebdavBaseService but I'm not sure at all that I'm on the right way? >> >> >> Thank you very much for your replies, >> >> >> Benoit Pironet >> >> >> >> I'm using Jahia 5.0.3 >> _______________________________________________ >> dev_list mailing list >> dev_list@... >> http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list >> >> > > _______________________________________________ > dev_list mailing list > dev_list@... > http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list > > _______________________________________________ dev_list mailing list dev_list@... http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list _______________________________________________ dev_list mailing list dev_list@... http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list |
| Free Forum Powered by Nabble | Forum Help |