As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> <html> <body> <f:view> <h:form> <r:template template="alfresco/templates/userhome_docs.ftl" /> </h:form> </f:view> </body> </html>
<r:template template="alfresco/templates/example.ftl" model="#{MyBean.templateModel}" /> Example Bean code to return a model: /** * Returns a model for use by a template on the Document Details page. * * @return model containing current document and current space info. */ public Map getTemplateModel() { Map<String, Object> model = new HashMap<String, Object>(4, 1.0f); model.put("document", getDocument().getNodeRef()); model.put("space", this.navigator.getCurrentNode().getNodeRef()); //define space that you need hire. model.put(TemplateService.KEY_IMAGE_RESOLVER, imageResolver); return model; }
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> <html> <body> <f:view> <h:form> <r:template template="alfresco/templates/simple.ftl" /> </h:form> </f:view> </body> </html>
<h1>hello how are you</h1>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> <r:template template="alfresco/templates/simple.ftl" />
This works great, check how to define custom model. and specify space and document nodes. this would fix it . <r:template template="alfresco/templates/example.ftl" model="#{MyBean.templateModel}" /> Example Bean code to return a model: /** * Returns a model for use by a template on the Document Details page. * * @return model containing current document and current space info. */ public Map getTemplateModel() { Map<String, Object> model = new HashMap<String, Object>(4, 1.0f); model.put("document", getDocument().getNodeRef()); model.put("space", this.navigator.getCurrentNode().getNodeRef()); //define space that you need hire. model.put(TemplateService.KEY_IMAGE_RESOLVER, imageResolver); return model; }
protected TemplateImageResolver imageResolver = new TemplateImageResolver() { public String resolveImagePathForName(String filename, FileTypeImageSize size) { FacesContext context = FacesContext.getCurrentInstance(); ServletContext servletContext = ((HttpServletRequest) context .getExternalContext().getRequest()).getSession() .getServletContext(); return FileTypeImageUtils.getFileTypeImage(servletContext, filename, size); } };
model.put("nodeList", this.browseBean.getContent());
<td style="padding-right:4px" align=right> <%– custom button –%> <nobr><a:actionLink value="CustomButton" image="/custom/images/icons/customButton.png" style="white-space:nowrap" actionListener="#{CustomDialog.myMethod}" id="mylink1" /></nobr> </td>
public class CustomDialog extends BaseDialogBean { Map<String, Object> templateModel; protected TemplateImageResolver imageResolver; public void myMethod(ActionEvent event) { imageResolver = new TemplateImageResolver() { public String resolveImagePathForName(String filename, FileTypeImageSize size) { FacesContext context = FacesContext.getCurrentInstance(); ServletContext servletContext = ((HttpServletRequest) context .getExternalContext().getRequest()).getSession() .getServletContext(); return FileTypeImageUtils.getFileTypeImage(servletContext, filename, size); } }; // go to custom dialog FacesContext fc = FacesContext.getCurrentInstance(); fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:custom"); } public Map getTemplateModel() { Map<String, Object> model = new HashMap<String, Object>(4, 1.0f); model.put("nodeList", this.browseBean.getContent()); model.put(TemplateService.KEY_IMAGE_RESOLVER, imageResolver); return model; } @Override protected String finishImpl(FacesContext context, String outcome) throws Exception { // return the default outcome return outcome; } public TemplateImageResolver getImageResolver() { return imageResolver; } public void setImageResolver(TemplateImageResolver imageResolver) { this.imageResolver = imageResolver; } public void setTemplateModel(Map<String, Object> templateModel) { this.templateModel = templateModel; } }
<dialog name="custom" page="/jsp/extension/dialogs/custom.jsp" managed-bean="CustomDialog" icon="/custom/images/icons/custom_1.gif" title="Custom" description="Displays custom list" />
<managed-bean> <managed-bean-name>CustomDialog</managed-bean-name> <managed-bean-class>co.esource.web.bean.CustomDialog</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property> <property-name>nodeService</property-name> <value>#{NodeService}</value> </managed-property> <managed-property> <property-name>browseBean</property-name> <value>#{BrowseBean}</value> </managed-property> </managed-bean>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> <r:template template="alfresco/templates/custom.ftl" model="#{CustomDialog.templateModel}" />
model.put("hello","hello, how are you");
public Map getTemplateModel() { nameList = new java.util.ArrayList<String>(); customList = new java.util.ArrayList<customNode>(); List<Node> searchResults = this.browseBean.getContent(); Integer searchResultsCount = searchResults.size(); for(ListIterator<Node>li=searchResults.listIterator(); li.hasNext(); ) { Node resultNode = li.next(); String Name = resultNode.getName(); nameList.add(Name); customList.add(new customNode(resultNode)); } Map<String, Object> model = new HashMap<String, Object>(4, 1.0f); model.put("names", nameList); model.put("custom", customList); //model.put("nodeList", this.browseBean.getContent()); model.put(TemplateService.KEY_IMAGE_RESOLVER, imageResolver); return model; }
childrenByLuceneSearch Returns a map capable of executing a search against the entire repository based on a Lucene search string. It returns a sequence of nodes which represent the objects from the results of the search, such as companyhome.childrenByLuceneSearch["TEXT:alfresco* AND TEXT:tutorial*"]. The value can be any valid Lucene search string supported by Alfresco. Note that you may need to escape Lucene specific characters. Note that the entire repository is searched: the current node is only used as an access point to retrieve the search object.