cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Cascading Constraints

thestorm
Champ in-the-making
Champ in-the-making
Hey people,

i found the Cascading Constraints from Jean Barmash (http://blogs.alfresco.com/wp/jbarmash/2008/08/08/dynamic-data-driven-drop-downs-for-list-properties/)and need them for my current project. What i wanna do is to generate the List of values out of spaces that are in my customer folder. My problem is now to set the Lucene query for the constraint.


<constraint name=”my:customConstraint”
type=”org.alfresco.sample.constraints.LuceneSearchBasedListConstraint” >
<parameter name=”query”>
<value> TYPE:”{http://www.alfresco.org/model/content/1.0}folder” AND@\http://www.alfresco.org/model/content/1.0\}name:'Customer"
</value>
</parameter>
</constraint>

I get following error in the log file:


22:35:01,259 User:System ERROR [web.context.ContextLoader] Context initialization failed
net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext
        at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:477)
        at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:355)
        at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:77)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:275)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy23.query(Unknown Source)
        at org.alfresco.sample.constraints.LuceneSearchBasedListConstraint.getSearchResult(LuceneSearchBasedListConstraint.java:69)
        at org.alfresco.sample.constraints.SearchBasedListConstraint.getAllowedValues(SearchBasedListConstraint.java:62)

I think it is related to my Lucene query not working. Can some1 please help me.
27 REPLIES 27

thestorm
Champ in-the-making
Champ in-the-making
I was in talk with jbmarsh the creator of this constraints and he didnt find an solution either. In the end i was stickin with 3.0

and I didn't raise any JIRA 🙂

thestorm
Champ in-the-making
Champ in-the-making
I was in talk with jbmarsh the creator of this constraints and he didnt find an solution either. In the end i was stickin with 3.0

and I didn't raise any JIRA since 3.0 was working for me.

I suggest u set up a 3.0 test area and create the constraints there if they are working try to by-pass the security context with the exactly same config. This custom constraints are tough in some cases. Some of them bothered me 3 days just cause a space was missing somewhere Smiley Happy

If you find a way to run it in 3.2++++ I'd be happy if u share it since I don't like to run productive on an outdated version

dynamolalit
Champ on-the-rise
Champ on-the-rise
Hi Storm,

I spent 5 days to resolve the issue but could not do it. :cry: .I tried everything i could including services,app context, faces context, impl etc etc.

I am thinking of raising a JIRA for this issue as it is not working but not sure if it is OK to do so after so long .:roll:

My ultimate goal is to get it working on 3.2 which i am sure is not working properly. :arrow:

Anyhow if i will get anything positive, i will post it here.   Smiley Happy

P.S. Can you please let me know what changes have been made to security context post 3.0 or any pointer so that i can try something else.

dynamolalit
Champ on-the-rise
Champ on-the-rise
Hi,

I  tried an alternative which gives me list of categories as checkboxes which i can select & using a button,i can associate them with the content uploaded in a space using 'Add Content' link.I have created a bean named AddCategoryBean.java which is having method named saveCategories() which is trying to save categories with content uploaded in previous step which is like this:

public String saveCategories() {
      logger.debug("Inside saveCategories()");
      addCheckedRows();
      String outcome = "cancel";
      UserTransaction tx = null;
      NodeService nodeService = Repository.getServiceRegistry(
            FacesContext.getCurrentInstance()).getNodeService();
      try {
         FacesContext context = FacesContext.getCurrentInstance();
         tx = Repository.getUserTransaction(FacesContext
               .getCurrentInstance());
         tx.begin();
         // firstly retrieve all the properties for the current node
         Map updateProps = nodeService.getProperties(getDocument().getNodeRef());

         // create a node ref representation of the selected id and set the
         // new properties
         updateProps.put(ContentModel.PROP_CATEGORIES,
               (Serializable) this.categories);

         // set the properties on the node
         nodeService.setProperties(getDocument().getNodeRef(), updateProps);

         // commit the transaction
         tx.commit();

         // reset the state of the current document so it reflects the
         // changes just made
         getDocument().reset();

         outcome = "finish";
      } catch (Throwable e) {
         Utils.addErrorMessage(MessageFormat.format(
               Application.getMessage(FacesContext.getCurrentInstance(),
                     "error_update_category"), new Object[] { e
                     .getMessage() }), e);
      }
      return outcome;
   }
Now as soon as i click to add any category, i am getting this message on explorer:

Please correct the errors below then click OK.

* Failed to update category due to system error: null

Also i am  getting this error on server console:

8:39:06,935 User:km DEBUG [km.bean.AddCategoryBean] browseBean.getDocument() null
18:39:06,935 User:km DEBUG [km.bean.AddCategoryBean] getDocument() 1 null
18:39:06,935 User:km DEBUG [km.bean.AddCategoryBean] browseBean.getDocument() null
18:39:07,247 User:km ERROR [ui.common.Utils] Failed to update category due to system error: null
java.lang.NullPointerException
        at com.jindal.alfresco.km.bean.AddCategoryBean.saveCategories(AddCategoryBean.java:255)
        at com.jindal.alfresco.km.bean.AddCategoryBean.getLevelUpChildrenForNode(AddCategoryBean.java:129)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
        at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
        at javax.faces.component.UICommand.broadcast(UICommand.java:109)
        at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
        at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:139)
        at org.apache.myfaces.lifecycle.ApplyRequestValuesExecutor.execute(ApplyRequestValuesExecutor.java:32)
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:110)
        at sun.reflect.GeneratedMethodAccessor447.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.
java:122)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy210.doFilter(Unknown Source)
        at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
        at sun.reflect.GeneratedMethodAccessor447.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.
java:122)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy210.doFilter(Unknown Source)
        at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)

Line no 255 says this:

Map updateProps = nodeService.getProperties(getDocument().getNodeRef());

What i got from here is that i am not able to get noderef of the particular content uploaded with which i am struggling. :roll:

Any idea how to get noderef of content uploaded using 'Add Content' link in a space?

dynamolalit
Champ on-the-rise
Champ on-the-rise
Hi All,

Finally i got this working as i mentioned in my previous reply as i could get noderef by injecting browsebean for backing bean. Smiley Very Happy

Here is the code for chekcbox approach:

Backing Bean:

package com.xxxx.alfresco.km.bean;

import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Stack;

import javax.faces.component.UIData;
import javax.faces.component.UISelectBoolean;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.jcr.Session;
import javax.transaction.UserTransaction;

import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.CategoryService;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.search.CategoryService.Depth;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.UIContextService;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
import org.apache.log4j.Logger;

public class AddCategoryBean extends BaseDialogBean {

   private static Logger logger = Logger.getLogger(AddCategoryBean.class);
   private static final long serialVersionUID = 1L;
   private FacesContext context = FacesContext.getCurrentInstance();
   private List<NodeRef> categories;
   private Stack<NodeRef> parentCategories;
   private ArrayList<SelectItem> rootCategories;
   private Collection<ChildAssociationRef> childRefs;
   private List<AddCategoryItem> categoryItems;
   private UIData categoriesTable;// = new UIData();
   private static final String MSG_ERROR_UPDATE_CATEGORY = "error_update_category";

   // default constructor
   @SuppressWarnings("unchecked")
   public AddCategoryBean() {
      super();
      categories = (List<NodeRef>) FacesContext.getCurrentInstance()
            .getExternalContext().getSessionMap().get("savedCategories");
      if (categories == null)
         categories = new ArrayList<NodeRef>();
      parentCategories = new Stack<NodeRef>();
      categoryItems = new ArrayList<AddCategoryItem>();
      getRootChildren(context);
      // logger.debug("categories in AddCategoryBean() " + categories.size());
   }

   /**
    * get top level categories
    */
   private void getRootChildren(FacesContext context) {
      childRefs = getCategoryService().getCategories(
            Repository.getStoreRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE,
            Depth.IMMEDIATE);
      logger.debug("childRefs in AddCategoryBean() " + childRefs.size());
      for (int i = 0; i < childRefs.size(); i++) {
         logger.debug("Value in getRootChildren "
               + childRefs.iterator().next());
      }
      updateTableModel();
   }

   /**
    * get categories by nodeRef the nodeRef comes from the selected row
    */
   public String getChildrenForNode() {
      ChildAssociationRef assocRef = ((AddCategoryItem) categoriesTable
            .getRowData()).getChildRef();
      //logger.debug("assocRef in AddCategoryBean() " + assocRef.getQName());
      NodeRef nodeRef = new NodeRef(Repository.getStoreRef(), assocRef
            .getChildRef().getId());
      childRefs = getCategoryService().getChildren(nodeRef,
            CategoryService.Mode.SUB_CATEGORIES,
            CategoryService.Depth.IMMEDIATE);
      addCheckedRows();
      updateTableModel();
      ChildAssociationRef parentRef = Repository.getServiceRegistry(
            FacesContext.getCurrentInstance()).getNodeService()
            .getPrimaryParent(nodeRef);
      parentCategories.push(parentRef.getParentRef());
      UIContextService.getInstance(FacesContext.getCurrentInstance())
            .notifyBeans();
      return "success";
   }

   /**
    * get categories by nodeRef. the nodeRef comes from the stack that holds
    * the parent reference. this method is used to navigate one level up.
    */
   public String getLevelUpChildrenForNode() {
      if (!parentCategories.isEmpty()) {
         NodeRef parentRef = (NodeRef) this.parentCategories.pop();
         childRefs = getCategoryService().getChildren(parentRef,
               CategoryService.Mode.SUB_CATEGORIES,
               CategoryService.Depth.IMMEDIATE);
         //logger.debug("childRefs in AddCategoryBean() 2 " + childRefs);
         addCheckedRows();
         updateTableModel();
         UIContextService.getInstance(FacesContext.getCurrentInstance())
               .notifyBeans();

      }
      this.saveCategories();
      return "success";
   }

   /**
    * update table model with new values
    */
   public void updateTableModel() {
      categoryItems.clear();
      AddCategoryItem categoryItem = null;
      for (ChildAssociationRef ref : childRefs) {
         categoryItem = new AddCategoryItem();
         categoryItem.setChildRef(ref);
         if (categories.contains(ref.getChildRef())) {
            categoryItem.setSelected(true);
         }

         categoryItems.add(categoryItem);
      }
   }

   /**
    * Use Spring JSF integration to return the category service bean instance
    *
    * @param context
    *            FacesContext
    * @return category service bean instance or throws runtime exception if not
    *         found
    */
   private CategoryService getCategoryService() {
      CategoryService service = Repository.getServiceRegistry(context)
            .getCategoryService();
      if (service == null) {
         throw new IllegalStateException(
               "Unable to obtain CategoryService bean reference.");
      }
      return service;
   }
   
   


   /**
    * add selected rows to the "categories" collection the method will remove
    * rows that have been disselected from the "categories" collection!
    */
   private void addCheckedRows() {
      for (int i = 0; i < categoriesTable.getRowCount(); i++) {
         //logger.debug("categoriesTable in AddCategoryBean() 2 "+ categoriesTable);
         categoriesTable.setRowIndex(i);
         UISelectBoolean box = (UISelectBoolean) categoriesTable
               .findComponent("categoryCheckbox");
         boolean isSelected = box.isSelected();

         ChildAssociationRef assocRef = ((AddCategoryItem) categoriesTable
               .getRowData()).getChildRef();
         NodeRef currentRowRef = assocRef.getChildRef();
         if ((categories.contains(currentRowRef)) && !(isSelected)) {
            categories.remove(currentRowRef);
         }
         if ((isSelected) && !(categories.contains(currentRowRef))) {
            categories.add(currentRowRef);
         }
      }
   }

   /**
    * Updates the categories for the current document
    *
    * @return The outcome
    *
    *         public String saveCategories() { String outcome = "cancel";
    *         UserTransaction tx = null;
    *
    *         addCheckedRows(); try { tx =
    *         Repository.getUserTransaction(FacesContext
    *         .getCurrentInstance()); tx.begin(); NodeService nodeService =
    *         Repository.getServiceRegistry(
    *         FacesContext.getCurrentInstance()).getNodeService(); // firstly
    *         retrieve all the properties for the current node Map<QName,
    *         Serializable> updateProps = nodeService
    *         .getProperties(getNode().getNodeRef());
    *
    *         // create a node ref representation of the selected id and set
    *         the // new properties
    *         updateProps.put(ContentModel.PROP_CATEGORIES, (Serializable)
    *         this.categories);
    *
    *         // set the properties on the node
    *         this.getNodeService().setProperties(getNode().getNodeRef(),
    *         updateProps);
    *
    *         // commit the transaction tx.commit();
    *
    *         // reset the state of the current document so it reflects the //
    *         changes just made getNode().reset();
    *
    *         outcome = "finish"; } catch (Throwable e) { try { if (tx != null)
    *         { tx.rollback(); } } catch (Exception ex) { }
    *         Utils.addErrorMessage
    *         (MessageFormat.format(Application.getMessage(
    *         FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE_CATEGORY),
    *         e.getMessage()), e); }
    *
    *         return outcome; }
    */

   /**
    * Updates the categories for the current document
    *
    * @return The outcome
    */
   @SuppressWarnings({ "deprecation", "unchecked" })
   public String saveCategories() {
      logger.debug("Inside saveCategories()");
      //CustomEditContentPropertiesDialog dialog = new CustomEditContentPropertiesDialog();
      //NodeRef nodeRef1 = dialog.getNodeRef();
      //logger.debug("Inside saveCategories() nodeRef1 "+nodeRef1);
      addCheckedRows();
      String outcome = "cancel";
      UserTransaction tx = null;
      NodeService nodeService = Repository.getServiceRegistry(
            FacesContext.getCurrentInstance()).getNodeService();
      try {
         FacesContext context = FacesContext.getCurrentInstance();
         //Repository.getServiceRegistry(context).getCheckOutCheckInService()
         tx = Repository.getUserTransaction(FacesContext
               .getCurrentInstance());
         tx.begin();
         
         NodeRef nodeRef = null;
         try{
          nodeRef = this.browseBean.getActionSpace().getNodeRef();
          logger.debug("nodeRef in addcategorybean "+nodeRef);
         }catch (Exception e) {
            nodeRef = this.browseBean.getDocument().getNodeRef();
            logger.debug("nodeRef in addcategorybean @ 2 "+nodeRef);
         }
         //List<Node> list = browseBean.getContent();
         
         // firstly retrieve all the properties for the current node
         Map updateProps = nodeService.getProperties(nodeRef);

         // create a node ref representation of the selected id and set the
         // new properties
         updateProps.put(ContentModel.PROP_CATEGORIES,(Serializable) this.categories);

         // set the properties on the node
         nodeService.setProperties(nodeRef, updateProps);
         
         // commit the transaction
         tx.commit();

         // reset the state of the current document so it reflects the
         // changes just made
         getDocument().reset();

         outcome = "finish";
      } catch (Throwable e) {
         Utils.addErrorMessage(MessageFormat.format(
               Application.getMessage(FacesContext.getCurrentInstance(),
                     "error_update_category"), new Object[] { e
                     .getMessage() }), e);
      }
      return outcome;
   }

   public Node getDocument() {
      return getNode();
      //return browseBean.getDocument();
   }


   protected Node getLinkResolvedNode() {
      // TODO Auto-generated method stub
      return null;
   }

   public SearchService getSearchService() {
      SearchService service = Repository.getServiceRegistry(context)
            .getSearchService();
      if (service == null) {
         throw new IllegalStateException(
               "Unable to obtain CategoryService bean reference.");
      }
      return service;
   }
   
   public Node getNode() {
      // TODO Auto-generated method stub
      //return null;
      
      //BrowseBean browseBean = new BrowseBean();
      logger.debug("browseBean.getDocument() "+this.browseBean.getDocument());
      return this.browseBean.getDocument();
   }

   protected String getPropertiesPanelId() {
      // TODO Auto-generated method stub
      return null;
   }

   public Map getTemplateModel() {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   protected String finishImpl(FacesContext arg0, String arg1)
         throws Throwable {
      // TODO Auto-generated method stub
      return null;
   }

   public UIData getCategoriesTable() {

      return categoriesTable;
   }

   public void setCategoriesTable(UIData categoriesTable) {

      this.categoriesTable = categoriesTable;
   }

   public List getCategoryItems() {

      return categoryItems;
   }

   public void setCategoryItems(List categoryItems) {

      this.categoryItems = categoryItems;
   }

}

AddCategoryItem.java to support bean

package com.xxxx.alfresco.km.bean;

import org.alfresco.service.cmr.repository.ChildAssociationRef;

public class AddCategoryItem
{
   private ChildAssociationRef childRef;
   private boolean selected = false;
  
   public ChildAssociationRef getChildRef() {
      return childRef;
   }
   public void setChildRef(ChildAssociationRef childRef) {
      this.childRef = childRef;
   }
   public boolean isSelected() {
      return selected;
   }
   public void setSelected(boolean selected) {
      this.selected = selected;
   }
   public String getLocalName()
   {
      if(childRef != null)
      {
         return childRef.getQName().getLocalName();
      }
      return "";
   }
}

faces-config-beans.xml entry

<managed-bean>
   <description>
      Test Bean
   </description>
   <managed-bean-name>AddCategoryBean</managed-bean-name>
   <managed-bean-class>com.xxxx.alfresco.km.bean.AddCategoryBean</managed-bean-class>
   <managed-bean-scope>session</managed-bean-scope>   
   <managed-property>
         <property-name>browseBean</property-name>
         <value>#{BrowseBean}</value>
      </managed-property>   
      <managed-property>
         <property-name>nodeService</property-name>
         <value>#{NodeService}</value>
      </managed-property>
</managed-bean>

edit-content-properties.jsp under …/jsp/content

<%–
* Copyright (C) 2005-2007 Alfresco Software Limited.

* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception.  You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
–%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
<%@ page import="javax.faces.context.FacesContext"%>
<%@ page import="org.alfresco.web.app.Application"%>
<%@ page import="org.alfresco.web.bean.content.AddContentDialog"%>
<%@ page import="org.alfresco.web.app.servlet.FacesHelper"%>
<%@ page import="org.alfresco.web.ui.common.PanelGenerator"%>
<%@ page import="org.alfresco.web.bean.categories.EditNodeCategoriesDialog"%>

<%@ page import="org.alfresco.web.bean.categories.CategoriesDialog"%>
<%@ page import="org.alfresco.web.bean.CategoriesProperties"%>
<%@ page import="org.alfresco.service.cmr.search.CategoryService "%>
<%@ page import="org.alfresco.web.bean.wcm.AVMBrowseBean"%>

<%@ page import="org.alfresco.web.bean.content.EditContentPropertiesDialog"%>
<%@ page import="org.alfresco.web.bean.repository.Node"%>
<%@ page import="org.alfresco.web.bean.BrowseBean"%>

<%

%>
<f:verbatim>
<table cellpadding="2" width="100%" style="padding-top: 4px; padding-bottom: 4px;">
<tr class="wizardSectionHeading">
<td>
</f:verbatim>
<h:outputText value=" #{msg.properties}" escape="false" />
<f:verbatim></td>

</tr>
</table>
</f:verbatim>
<r:propertySheetGrid id="content-props" value="#{DialogManager.bean.editableNode}"
var="editContentProps" columns="1" externalConfig="true" />
<table>
<tr>
<td>Add Category:
</td>
<td align='right'>

<!– To show KP Domain categories ONLY –>
<h:commandButton image="/images/icons/add.gif" action="#{AddCategoryBean.getLevelUpChildrenForNode}" rendered="true" immediate="true">
</h:commandButton>
<h:dataTable id="categoriesTable" border="1" binding="#{AddCategoryBean.categoriesTable}" value="#{AddCategoryBean.categoryItems}" var="line">
     <h:column>
        <h:selectBooleanCheckbox value="#{line.selected}" id="categoryCheckbox"  immediate="true"/>
     </h:column>
     <h:column>
      <h:commandLink id="cmd-link" action="#{AddCategoryBean.getChildrenForNode}" immediate="true">
         <h:outputText id="output-text" value="#{line.localName}"/>
      </h:commandLink>
    </h:column>  
</h:dataTable>


</td></tr>
</table>



Now i want to display all categories as tree view. :roll:

Any idea on this will be highly appreciated.

bwagner
Champ in-the-making
Champ in-the-making
I'm experiencing problems with the example http://share.alfresco.com/share/page/site/community/document-details?nodeRef=workspace://SpacesStore...

My Steps:
- deployed a fresh sourcebuild of 3.2.r2 Community to Apache Tomcat 6.0.18 and populated the fresh database with some content - works
- added the example files under /projects/sdk/samples, built it and integrated the zip files with alfresco.war
- deployed alfresco.war - still works
- put exampleModel.xml, example-model-context.xml and web-client-config-custom.xml in tomcat-home/webapps/alfresco/WEB-INF/classes/alfresco/extension
- changed faces-config-beans.xml and faces-config-repo.xml as described in AddToFacesConfig.txt

and ran into the following

11:26:31,623  ERROR [web.context.ContextLoader] Context initialization failed
java.lang.NullPointerException
   at org.alfresco.sample.constraints.SearchBasedDependencyListConstraint.populateNodeValues(SearchBasedDependencyListConstraint.java:87)
   at org.alfresco.sample.constraints.SearchBasedDependencyListConstraint.resolveDependenciesOnProperties(SearchBasedDependencyListConstraint.java:40)
   at org.alfresco.sample.constraints.LuceneSearchBasedListConstraint.getSearchResult(LuceneSearchBasedListConstraint.java:64)
   at org.alfresco.sample.constraints.SearchBasedListConstraint.getAllowedValues(SearchBasedListConstraint.java:62)
   at org.alfresco.cmis.dictionary.CMISBasePropertyDefinition.<init>(CMISBasePropertyDefinition.java:108)
   at org.alfresco.cmis.dictionary.CMISAbstractTypeDefinition.createProperty(CMISAbstractTypeDefinition.java:154)
   at org.alfresco.cmis.dictionary.CMISAbstractTypeDefinition.createProperties(CMISAbstractTypeDefinition.java:133)
   at org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.init(CMISAbstractDictionaryService.java:416)
   at org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.afterDictionaryInit(CMISAbstractDictionaryService.java:502)
   at org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.onBootstrap(CMISAbstractDictionaryService.java:520)
   at org.alfresco.util.AbstractLifecycleBean.onApplicationEvent(AbstractLifecycleBean.java:62)
   at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
   at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
   at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
   at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
   at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:617)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
   at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:69)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
   at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
   at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
   at org.apache.catalina.core.StandardService.start(StandardService.java:516)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Apr 13, 2010 11:26:31 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Apr 13, 2010 11:26:31 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/alfresco] startup failed due to previous errors
….

bwagner
Champ in-the-making
Champ in-the-making
small update … after commenting out the use of the dependantConstraint I receive the

12:27:18,318  ERROR [web.context.ContextLoader] Context initialization failed
net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext

… already mentioned in other posts. Is there a way to get this example to work with 3.2?

thestorm
Champ in-the-making
Champ in-the-making
Hi All,

Finally i got this working as i mentioned in my previous reply as i could get noderef by injecting browsebean for backing bean. Smiley Very Happy

Here is the code for chekcbox approach:

Now i want to display all categories as tree view. :roll:

Any idea on this will be highly appreciated.

I don't really understand what your checkbox approach is, can you gimme a screenshot or sth!?


// bwagner as for now its not working in 3.2/3.3 … that's what we all need since the newest share improvements