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);
}
}
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>");
}
Aggregations