cancel
Showing results for 
Search instead for 
Did you mean: 

property requirements

bwagner
Champ in-the-making
Champ in-the-making
I've created a few content types and after taking a look at the configuration options, there are still requirements left:

- one properties value must be unique and it has to be therefore validated
- I have a property "publishDate" which must be set automatically when deployment is performed
- how can I achieve to use TinyMCE for more elements than just content? 

any hints where to start with customisation?
1 REPLY 1

hsohaib
Champ on-the-rise
Champ on-the-rise
you could create a node event listener like  :


package ma.samples.listeners;
import java.util.Date;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.NodeEventListener;
import org.alfresco.web.bean.repository.Node;

/**
*
* @author Haltout Sohaib
*/
public class CustomNodeListener implements NodeEventListener{
   
    private ServiceRegistry serviceRegistry;

    public ServiceRegistry getServiceRegistry() {
        return serviceRegistry;
    }

    public void setServiceRegistry(ServiceRegistry serviceRegistry) {
        this.serviceRegistry = serviceRegistry;
    }

    public void created(Node node, QName type) {
        if(node.hasProperty("publishDate")){
            //change MyContentModel.PROP_PUB_DATE by your property's QName
            serviceRegistry.getNodeService().setProperty(node.getNodeRef(), MyContentModel.PROP_PUB_DATE, new Date());
           
        }
       
        if(node.hasProperty("MyUniqueProperty")){
            //Check if its unique, if not throw an exception
           
        }
       
    }

}

add your listener bean to your model context :


<beans>
….
<bean id="nodeListenerBean" class="ma.samples.listeners.CustomNodeListener">
        <property name="serviceRegistry">
              <ref bean="ServiceRegistry" />
         </property>
</bean>
…..
</beans>


And then tell Alfresco you want your bean to be notified whenever a new node is created by adding the fellowing config to your web-client-config-custom.xml :


  <config evaluator="string-compare" condition="Node Event Listeners">

      <node-event-listeners>
         <listener>nodeListenerBean</listener>
      </node-event-listeners>
   </config>

Hope it helps.