template variables
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2007 02:06 PM
Hi guys!
I have a custom.jsp in which i call a template
<r:template id="template" template="alfresco/templates/custom.ftl"/>
and here is the code for custom.ftl
if i call the JSP, i have an error saying that variables space is not defined :
I have read in the wiki (http://wiki.alfresco.com/wiki/Template_Guide😞
how can i get the current node ?
please give me a hint
thanks in advance
I have a custom.jsp in which i call a template
<r:template id="template" template="alfresco/templates/custom.ftl"/>
and here is the code for custom.ftl
<table> <#list space.children as child> <#if child.isDocument> <tr> <td><img src="/alfresco${child.icon16}"></td> <#assign ref=child.nodeRef> <#assign workspace=ref[0..ref?index_of("://")-1]> <#assign storenode=ref[ref?index_of("://")+3..]> <td><a href="/alfresco/navigate/showDocumentDetails/${workspace}/${storenode}"><b>${child.properties.name}</b></a> (${child.children?size})</td> </tr> </#if> </#list></table>
the code is nearly similar to my_spaces.ftlif i call the JSP, i have an error saying that variables space is not defined :
Caused by: freemarker.core.InvalidReferenceException: Expression space is undefi
ned on line 4, column 11 in alfresco/templates/custom.ftl.
at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134)
at freemarker.core.Dot._getAsTemplateModel(Dot.java:78)
at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
at freemarker.core.IteratorBlock.accept(IteratorBlock.java:87)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.Environment.process(Environment.java:176)
at freemarker.template.Template.process(Template.java:232)
at org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:205)
… 61 more
I have read in the wiki (http://wiki.alfresco.com/wiki/Template_Guide😞
If you are accessing the templates through the Space Preview action, the Template Servlet or through the Space Dashboard then the following named object is also provided:
space
The current space template node.
how can i get the current node ?
please give me a hint
thanks in advance
Labels:
- Labels:
-
Archive
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2007 06:04 AM
The objects that are available depend on your context, as the wiki states:
You are not using the template servlet or space dashboard view. You can bind in any model you want to the UITemplate component you are using, so add the following code to your JSF managed bean:
For the code above, you will need to add the NavigationBean to your JSF managed bean definition config:
Add modify your template jsp, this assumes your JSF managed bean is called 'mybean' - change it as appropriate:
Hope this helps,
Kevin
If you are accessing the templates through the Space Preview action, the Template Servlet or through the Space Dashboard then the following named object is also provided:
space
The current space template node.
You are not using the template servlet or space dashboard view. You can bind in any model you want to the UITemplate component you are using, so add the following code to your JSF managed bean:
public Map getTemplateModel() { Map<String, Object> model = new HashMap<String, Object>(1, 1.0f); FacesContext fc = FacesContext.getCurrentInstance(); TemplateNode spaceNode = new TemplateNode(this.navigator.getCurrentNode().getNodeRef(), Repository.getServiceRegistry(fc), imageResolver); model.put("space", spaceNode); return model; } /** Template Image resolver helper */ private TemplateImageResolver imageResolver = new TemplateImageResolver() { public String resolveImagePathForName(String filename, boolean small) { return Utils.getFileTypeImage(filename, small); } };
For the code above, you will need to add the NavigationBean to your JSF managed bean definition config:
<managed-property> <property-name>navigator</property-name> <value>#{NavigationBean}</value> </managed-property>
Add modify your template jsp, this assumes your JSF managed bean is called 'mybean' - change it as appropriate:
<r:template template="alfresco/templates/userhome_docs.ftl" model="#{mybean.templateModel}" />
Hope this helps,
Kevin
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2007 02:06 PM
yeah this really helps!
thanks a lot
Alfresco upper, higher and stronger :wink:
thanks a lot
Alfresco upper, higher and stronger :wink:
