[opencms-dev] How to list files from a folder in opencms?

Patric Dosch patric.dosch at virtual-identity.com
Tue Mar 14 16:22:49 CET 2017


>> I need to change a field from the resource type any time another field gets modified.
That does not work. When the listOfFiles is generated from your formatter.

>> I guess that regenerating the listOfFiles any time the page loads is not a good idea
That’s not a good idea 😊, but opencms have some kinds of caching.
Flex Cache generated the list only once (until something is published).
http://documentation.opencms.org/opencms-documentation/caching-in-opencms/the-flex-cache/index.html
I don’t know how many files you have to read, maybe that flex cache is ok.

Maybe you the new cms:search http://documentation.opencms.org/opencms-documentation/demos/lists-and-detail-pages-ii/index.html can help to, but the caching issue is the same.

Or you have to build your own cache, but with own cache implementations I have so far only bad experiences.

So I hope I can help you.
But I find it quite hard to answer your questions, because with each new mail new requirements appear and I have not seen any line code so far.

Regards, Patric







Von: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] Im Auftrag von mihai lacusteanu
Gesendet: Dienstag, 14. März 2017 15:43
An: The OpenCms mailing list <opencms-dev at opencms.org>
Betreff: Re: [opencms-dev] How to list files from a folder in opencms?

But is there a way to modify the content? I need to change a field from the resource type any time another field gets modified.
I have 2 fields: folder, and listOfFiles and I need to update the listOfFiles field any time the folder field gets modified.
I don't know how to do that in the formatter..or there is another place for putting my code?(I guess that regenerating the listOfFiles any time the page loads is not a good idea)

On Tue, Mar 14, 2017 at 4:20 PM, Patric Dosch <patric.dosch at virtual-identity.com<mailto:patric.dosch at virtual-identity.com>> wrote:
Hey Mihai,

>> I don't know how to read data from the resource type(xml), which I can access using el expression.
But ${value.YourFieldName} is an el expression.
Now you need the value in your java world? Correct?


The best way should be to use a el-function. This https://newfivefour.com/tomcat7-el-custom-function.html seems to be a nice example. As far as I know the web.xml stuff is not needed anymore.


A not so nice way:

<c:set var=”yourVar” value=”${value.YourFieldName}”/>

<%
String yourVar = (String) pageContext.getAttribute(“yourVar”);
%>

Hope to understand your problem correctly.
But that are java questions and not opencms questions 😊

Regards, Patric



Von: opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org> [mailto:opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org>] Im Auftrag von mihai lacusteanu
Gesendet: Mittwoch, 8. März 2017 15:09
An: opencms-dev at opencms.org<mailto:opencms-dev at opencms.org>
Betreff: Re: [opencms-dev] How to list files from a folder in opencms?

I don't need the value to be rendered in the HTML, I need to process it in the formatter (in the Java code between <% %>. Any time the resource type is processed via formatter I need to get a url from a field and then process it, not just output it in the HTML using el expressions.
How can I do that?

Thanks!
Mihai

Pe 8 mar. 2017 4:01 p.m., "Patric Dosch" <patric.dosch at virtual-identity.com<mailto:patric.dosch at virtual-identity.com>> a scris:
>> I don't know how to read data from the resource type(xml), which I can access using el expression.
This should help: http://documentation.opencms.org/opencms-documentation/content-in-opencms/formatters-and-their-configuration/index.html#4.2

So ${value.YourFieldName} holds the information

Regards, Patric


Von: opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org> [mailto:opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org>] Im Auftrag von mihai lacusteanu
Gesendet: Dienstag, 7. März 2017 16:49
An: opencms-dev at opencms.org<mailto:opencms-dev at opencms.org>
Betreff: [opencms-dev] How to list files from a folder in opencms?

I need to create a new resource type in opencms which have 1 field. The field is for a target folder.
Every time I select a folder from VFS and save the resource(xml) the formatter will render a the list of files from the specified folder.

I managed to create a jsp file which will create the list of files needed, but only with the target folder hardcoded. I don't know how to read data from the resource type(xml), which I can access using el expression.
Can you help me?

_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev



_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20170314/676d80c4/attachment.htm>


More information about the opencms-dev mailing list