User Tools

Site Tools


forum:alfresco:custom-action

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

forum:alfresco:custom-action [2008/05/23 12:02]
sebastian
forum:alfresco:custom-action [2023/11/19 22:46] (current)
Line 37: Line 37:
   - Part one is about creating the QuickCheckout as a custom action. This action will be available in the list of actions for a document.   - Part one is about creating the QuickCheckout as a custom action. This action will be available in the list of actions for a document.
   - Part two shows how to make this action available as a button in the web client UI.   - Part two shows how to make this action available as a button in the web client UI.
 +For deployment it is assumed that there is an exploded alfresco.war in the deployment directory of the application server. The action is available as soon as the files are copied into the specified directories and the application server is restarted. The names of the files are given above the file contents. The directory the files have to be deployed to can be found at the bottom of the file contents.
  
 ==== Part 1: Creating a custom action ==== ==== Part 1: Creating a custom action ====
Line 47: Line 48:
 === The action class === === The action class ===
 The QuickCheckout class is the actual implementation of the QuickCheckout action. It extends ActionExecuterAbstractBase and overrides executeImpl(). This method will later be called to start the action. The QuickCheckout class is the actual implementation of the QuickCheckout action. It extends ActionExecuterAbstractBase and overrides executeImpl(). This method will later be called to start the action.
 +
 +''​QuickCheckout.java''​
 <​code>​ <​code>​
 package de.hmedia.alfresco.actions;​ package de.hmedia.alfresco.actions;​
Line 230: Line 233:
         return targetSubFolder;​         return targetSubFolder;​
     }     }
 +
  
     /**     /**
Line 240: Line 244:
 } }
 </​code>​ </​code>​
-The class must be copied to /deploy/​Alfresco.war/​WEB-INF/​classes.+The class must be copied to deploy/​Alfresco.war/​WEB-INF/​classes.
  
 === The messages file === === The messages file ===
 The messages file for an action must at least contain a title and a description for the action. The messages file for an action must at least contain a title and a description for the action.
 +
 ''​quick-checkout-messages.properties''​ ''​quick-checkout-messages.properties''​
 <​code>​ <​code>​
Line 253: Line 258:
 </​code>​ </​code>​
  
-The file has to be saved in /conf/​alfresco/​extension+The file has to be saved in conf/​alfresco/​extension
  
 === Adding the action to the Spring context === === Adding the action to the Spring context ===
-To make the action class available for Alfresco it has to be added in the Spring context. While adding it to the context the QuickCheckout class can also be given references to other classes already available in the Alfresco Spring context. That is how the parameters needed be the class are set. A reference to the message properties file of the QuickCheckout action must also be given here.+To make the action class available for Alfresco it has to be added in the Spring context. While adding it to the context the QuickCheckout class can also be given references to other classes already available in the Alfresco Spring context. That is how the parameters needed be the class are set. A reference to the message properties file of the QuickCheckout action must also be given here. This is done in the bean with id ''​extension.actionResourceBundles''​ in the ''​resourceBundles''​ property.
  
 ''​quick-checkout-context.xml''​ ''​quick-checkout-context.xml''​
Line 296: Line 301:
 </​code>​ </​code>​
  
-The file has to be saved in /conf/​alfresco/​extension+The file has to be saved in conf/​alfresco/​extension 
  
 ==== Part 2: Making the action available to the web client ==== ==== Part 2: Making the action available to the web client ====
Line 302: Line 308:
   - Create a backing bean for the action.   - Create a backing bean for the action.
   - Make the backing bean managed.   - Make the backing bean managed.
 +  - Create an icon for the action.
   - Customize the web client configuration to include the action.   - Customize the web client configuration to include the action.
 For the rest of this example some Java Server Faces (JSF) knowledge is presumed. For the rest of this example some Java Server Faces (JSF) knowledge is presumed.
Line 308: Line 315:
 The backing bean has a ''​doQuickCheckout''​ method that will later be bound as a JSF action listener to the quick checkout button. This method will call the QuickCheckout class to actually do the quick checkout. If the checkout was successful the navigation will be set to the space where the checked out file can be found. The backing bean has a ''​doQuickCheckout''​ method that will later be bound as a JSF action listener to the quick checkout button. This method will call the QuickCheckout class to actually do the quick checkout. If the checkout was successful the navigation will be set to the space where the checked out file can be found.
  
-This is the code of the backing bean:+This is the code of the backing bean ''​QuickCheckoutBean.java''​:
  
 <​code>​ <​code>​
Line 459: Line 466:
 </​code>​ </​code>​
  
-The class must be copied to /deploy/​Alfresco.war/​WEB-INF/​classes.+The class must be copied to deploy/​Alfresco.war/​WEB-INF/​classes.
  
 === Making the backing bean managed === === Making the backing bean managed ===
 To make the backing bean a JSF managed bean the bean has to be listed in the faces-config-custom.xml file. This file can be found in deploy/​alfresco.war/​WEB-INF. The properties needed by the backing bean have to be set here too. To make the backing bean a JSF managed bean the bean has to be listed in the faces-config-custom.xml file. This file can be found in deploy/​alfresco.war/​WEB-INF. The properties needed by the backing bean have to be set here too.
  
 +''​faces-config-custom.xml''​
 <code xml> <code xml>
 <?xml version='​1.0'​ encoding='​UTF-8'?>​ <?xml version='​1.0'​ encoding='​UTF-8'?>​
Line 474: Line 482:
    <​!-- initialisation. Overwrite this file with your custom version. ​  ​-->​    <​!-- initialisation. Overwrite this file with your custom version. ​  ​-->​
    <​!-- *************************************************************** -->    <​!-- *************************************************************** -->
 +
        
    <​managed-bean>​    <​managed-bean>​
Line 502: Line 511:
 </​faces-config>​ </​faces-config>​
 </​code>​ </​code>​
 +
 +This file resides in the deploy/​alfresco.war/​WEB-INF directory
 +
 +=== The icon for the action ===
 +Action icons are available in the deploy/​alfresco.war/​images directory. A custom icon can be added there. See next section for how to attach the icon to the action.
  
 === Including the action in the web client === === Including the action in the web client ===
-To make the action available to Alfresco the web-client-config-custom.xml file has to be altered. This file resides in the /conf/​alfresco/​extension/​ directory. The following lines have to be added:+To make the action available to Alfresco the web-client-config-custom.xml file has to be altered. This file resides in the conf/​alfresco/​extension/​ directory. The following lines have to be added to ''​web-client-config-custom.xml''​:
 <code xml> <code xml>
 <​config>​ <​config>​
Line 529: Line 543:
         <!-- Actions Menu for Document Details screen -->         <!-- Actions Menu for Document Details screen -->
         <​action-group id="​doc_details_actions">​         <​action-group id="​doc_details_actions">​
-            <action idref="​quitck_checkout_doc" />+            <action idref="​quick_checkout_doc" />
         </​action-group>​         </​action-group>​
     </​actions>​     </​actions>​
Line 535: Line 549:
 </​code>​ </​code>​
  
 +This file resides in the conf/​alfresco/​extension/​ directory
  
 ===== TODO ===== ===== TODO =====
-  * The bean classes shouldn'​t reside directly in the alfresco.war deploy dir. +  * The bean classes shouldn'​t reside directly in the alfresco.war deploy dir. This can be achived by packaging ​the files into an Alfresco module (.amp) file.
-  * The doQuickCheckout method of QuickCheckoutBean contains ​the name of the target subfolderThis should be given as a parameter.+
  
 ~~DISCUSSION~~ ~~DISCUSSION~~
forum/alfresco/custom-action.1211544150.txt.gz · Last modified: 2023/11/19 22:45 (external edit)