cancel
Showing results for 
Search instead for 
Did you mean: 

access Alfresco file directory?

esource
Champ on-the-rise
Champ on-the-rise
with Java, from within Alfresco, what is the correct syntax, what classes do I call, to access the Alfresco file directory?  For example if I want to access with Java the templates located under …\WEB-INF\classes\alfresco\templates\  how can I do this?
10 REPLIES 10

esource
Champ on-the-rise
Champ on-the-rise
for instance how can we access with Java:

…tomcat\shared\classes\alfresco\extension\templates?

gyro_gearless
Champ in-the-making
Champ in-the-making
SInce you may assume that both tomcat/shared/classes and alfresco/WEB-INF/classes are in the classpath, you can access them as resource.
Something like that (untested):

ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream is = cl.getResourceAsStream("/alfresco/templates/foobar.ftl")

HTH
Gyro

esource
Champ on-the-rise
Champ on-the-rise
Thank you for the post, but how can I access the freemarker template in a way that would allow me to apply against a node or array or set of data?  Also how can I create a file and write to it in the Alfresco file system?  For instance:

../tomcat/shared/classes/alfresco/extension/output/someoutput.html

esource
Champ on-the-rise
Champ on-the-rise
also how can I call

tomcat\shared\classes\alfresco\extension\templates

as a href in a jsf component in .jsp?

esource
Champ on-the-rise
Champ on-the-rise
SInce you may assume that both tomcat/shared/classes and alfresco/WEB-INF/classes are in the classpath, you can access them as resource.
Something like that (untested):

ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream is = cl.getResourceAsStream("/alfresco/templates/foobar.ftl")

HTH
Gyro

Is there a way I can get an output stream instead of an input stream?

mrogers
Star Contributor
Star Contributor
You probably want to load your script into the alfresco data dictionary rather than the file system.

esource
Champ on-the-rise
Champ on-the-rise
You probably want to load your script into the alfresco data dictionary rather than the file system.

Thank you for the suggestion, but I wanted to generate an html file to display in a new window from a jsf actionlink.  If I store the generated html in a node, how do I retrieve it and call it from the jsp opening it in a new window?

esource
Champ on-the-rise
Champ on-the-rise
Okay, I have it working.  Thank you for all the suggestions!

esource
Champ on-the-rise
Champ on-the-rise
You probably want to load your script into the alfresco data dictionary rather than the file system.

One question.  What is the correct syntax to display html that I've loaded into a node in a jsp page?

I've tried:

<r:template template="#{DialogManager.bean.displayUrl}" />

<%@ include file="${url.context}#{DialogManager.bean.displayUrl}"%>

<jsp:include page="${url.context}#{DialogManager.bean.displayUrl}" />