Search in sources :

Example 1 with CategoryBrowserBean

use of org.alfresco.web.bean.CategoryBrowserBean in project acs-community-packaging by Alfresco.

the class UICategoryBrowser method broadcast.

/*
    * (non-Javadoc)
    * 
    * @see org.alfresco.extension.web.ui.repo.component.UINavigator#broadcast(javax.faces.event.FacesEvent)
    */
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
    if (event instanceof CategoryBrowserEvent) {
        FacesContext context = FacesContext.getCurrentInstance();
        CategoryBrowserEvent categoryBrowseEvent = (CategoryBrowserEvent) event;
        NodeRef nodeClicked = new NodeRef(categoryBrowseEvent.getItem());
        boolean subcategories = categoryBrowseEvent.isIncludeSubcategories();
        if (logger.isDebugEnabled())
            logger.debug("Selected category: " + nodeClicked + " subcategories? " + subcategories);
        CategoryBrowserBean categoryBrowserBean = (CategoryBrowserBean) FacesHelper.getManagedBean(context, CategoryBrowserBean.BEAN_NAME);
        categoryBrowserBean.setCurrentCategory(nodeClicked);
        categoryBrowserBean.setIncludeSubcategories(subcategories);
        SearchContext categorySearch = categoryBrowserBean.generateCategorySearchContext();
        NavigationBean nb = (NavigationBean) FacesHelper.getManagedBean(context, NavigationBean.BEAN_NAME);
        nb.setSearchContext(categorySearch);
        context.getApplication().getNavigationHandler().handleNavigation(context, null, "category-browse");
    } else {
        super.broadcast(event);
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) NodeRef(org.alfresco.service.cmr.repository.NodeRef) NavigationBean(org.alfresco.web.bean.NavigationBean) SearchContext(org.alfresco.web.bean.search.SearchContext) CategoryBrowserBean(org.alfresco.web.bean.CategoryBrowserBean)

Example 2 with CategoryBrowserBean

use of org.alfresco.web.bean.CategoryBrowserBean in project acs-community-packaging by Alfresco.

the class UICategoryBrowser method encodeBegin.

/*
    * (non-Javadoc)
    * 
    * @see org.alfresco.web.ui.repo.component.UINavigator#encodeBegin(javax.faces.context.FacesContext)
    */
@Override
public void encodeBegin(FacesContext context) throws IOException {
    if (!isRendered())
        return;
    // TODO: pull width and height from user preferences and/or the main config,
    // if present override below using the style attribute
    ResponseWriter out = context.getResponseWriter();
    CategoryBrowserPluginBean categoryBrowserPluginBean = (CategoryBrowserPluginBean) FacesHelper.getManagedBean(context, CategoryBrowserPluginBean.BEAN_NAME);
    CategoryBrowserBean categoryBrowserBean = (CategoryBrowserBean) FacesHelper.getManagedBean(context, CategoryBrowserBean.BEAN_NAME);
    List<TreeNode> rootNodes = null;
    rootNodes = categoryBrowserPluginBean.getCategoryRootNodes();
    // order the root nodes by the tree label
    if (rootNodes != null && rootNodes.size() > 1) {
        QuickSort sorter = new QuickSort(rootNodes, "name", true, IDataContainer.SORT_CASEINSENSITIVE);
        sorter.sort();
    }
    // main container div
    out.write("<div id=\"category-navigator\" class=\"navigator\">");
    // Subcategories parameter
    String includeSub = Application.getMessage(context, "category_browser_plugin_include_subcategories");
    out.write("<input type='checkbox' id='" + SUBCATEGORIES_PARAM + "' name='" + SUBCATEGORIES_PARAM + "' value=1 " + (categoryBrowserBean.isIncludeSubcategories() ? "checked" : "") + "/>");
    out.write("<label for='" + SUBCATEGORIES_PARAM + "'>" + includeSub + "</label>");
    // generate the javascript method to capture the tree node click events
    out.write("<script type=\"text/javascript\">");
    out.write("function treeNodeSelected(nodeRef) {");
    out.write(Utils.generateFormSubmit(context, this, getClientId(context), "nodeRef", true, null));
    out.write("}</script>");
    // generate the active panel containing the tree
    out.write("<div class=\"navigatorPanelBody\">");
    UITree tree = (UITree) context.getApplication().createComponent(UITree.COMPONENT_TYPE);
    tree.setId("tree");
    tree.setRootNodes(rootNodes);
    tree.setRetrieveChildrenUrl(AJAX_URL_START + ".retrieveChildren?");
    tree.setNodeCollapsedUrl(AJAX_URL_START + ".nodeCollapsed?");
    tree.setNodeSelectedCallback("treeNodeSelected");
    tree.setNodeCollapsedCallback("informOfCollapse");
    Utils.encodeRecursive(context, tree);
    out.write("</div>");
    out.write("</div>");
}
Also used : CategoryBrowserPluginBean(org.alfresco.web.bean.ajax.CategoryBrowserPluginBean) QuickSort(org.alfresco.web.data.QuickSort) ResponseWriter(javax.faces.context.ResponseWriter) TreeNode(org.alfresco.web.ui.repo.component.UITree.TreeNode) CategoryBrowserBean(org.alfresco.web.bean.CategoryBrowserBean)

Aggregations

CategoryBrowserBean (org.alfresco.web.bean.CategoryBrowserBean)2 FacesContext (javax.faces.context.FacesContext)1 ResponseWriter (javax.faces.context.ResponseWriter)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 NavigationBean (org.alfresco.web.bean.NavigationBean)1 CategoryBrowserPluginBean (org.alfresco.web.bean.ajax.CategoryBrowserPluginBean)1 SearchContext (org.alfresco.web.bean.search.SearchContext)1 QuickSort (org.alfresco.web.data.QuickSort)1 TreeNode (org.alfresco.web.ui.repo.component.UITree.TreeNode)1