Custom Action UI Pre 1.3

From AlfrescoWiki

Jump to: navigation, search

IMPORTANT: This document details the Custom Action UI for Alfresco pre-1.3. For more recent versions then please see this document: Custom Action UI. Note that this page will no longer be maintained or updated except to correct any mistakes.

Contents

[edit] Adding UI for a Custom Action

During this tutorial we will assume that we have already created a custom action with the id 'action-id' and that it requires one parameter value with id 'param-name'.

[edit] Adding the navigation configuration for the custom action

  1. Open faces-config-navigation.xml found in web/WEB-INF.
  2. Search for '/jsp/wizard/new-rule/*'.
  3. Add the navigation case to the rule wizard:
     <navigation-case>
        <from-outcome>action-id</from-outcome>
        <to-view-id>/jsp/wizard/new-rule/action-id.jsp</to-view-id>
     </navigation-case>
  1. Search for '/jsp/wizard/create-action/*'.
  2. Add the navigation case to the new action wizard:
     <navigation-case>
        <from-outcome>action-id</from-outcome>
        <to-view-id>/jsp/wizard/create-action/action-id.jsp</to-view-id>
     </navigation-case>


[edit] Create the action UI

  1. Navigate to /web/jsp/wizard/new-rule.
  2. Create action-id.jsp. See action-add-features.jsp. Things to note:
    • The title id must be unique and is used to I18N the title of the page.
    • The form should also have a unique id.
  3. Add the controls that will allow the user to enter the parameter values of the action. Things to note:
    • Any methods that need to be added to support the population of a control should be added to BaseActionWizard.java
    • The values of parameters should be stored in the actionProperties map found on the BaseActionWizard.

[edit] Adding the display strings for the action

  1. Open config/alfresco/messages/webclient.properties.
  2. Add the title string:
  this_is_the_title_id_of_the_new_action=This is the title of the action
  1. Add the summary string for the action:
  action_<the id of the action with dashes replaced with underscores>=The description of the action used in the summary
  1. Open config/alfresco/messages/action-config.properties.
  2. Add the title and description strings. These will appear in drop down lists when selecting and configuring the action. Follow the entries under # Actions, such as:
   action.title=This is the title of the action
   action.description=This is the description of the action

[edit] Modify backing bean to correctly set parameters and summaries

  1. Open org.alfresco.web.bean.wizard.BaseActionWizard.java.
  2. Search for 'protected Map<String, Serializable> buildActionParams()'.
  3. Add the code to map the parameters from the actionProperties map into the action itsself.
  4. Search for 'protected void populateActionFromProperties(Map<String, Serializable> actionProps)'.
  5. Add the code to map the parameters of the action back into the actionProperties map.
  6. Open org.alfresco.web.bean.wizard.NewRuleWizard.java
  7. Search for 'protected String buildActionSummary(Map<String, Serializable> props)'
  8. Add the code to generate the summary message for the action.

[edit] Enabling the action in the 'Run Action' dialog

  1. Follow the steps for creating the action UI, but create a new file in /web/jsp/wizard/create-action.