Nuxeo Server

How to Add a Button in the JSF UI

Updated: October 13, 2017 Page Information Edit on GitHub

This page is scheduled for review and update. Check back soon for updated content!

Users actions are UI elements that the user will use to do an action in the application. It can be a link, an icon, a button. There are different categories of actions, that determine where they are displayed and under which form (button, icon, etc.). Clicking a user action will then trigger an automation chain.

Adding a Button in the JSF UI

Let's add a new button to approve a document. This button should be displayed with the other icons in the top right corner of a document view. This is the user action category Contextual tools (see the page Actions Display for all categories). When the clicks that icon, the document should change lifecycle state to Approved and its version should be incremented and its description updated with "Hello World".

To add a new button in the Nuxeo Platform JSF UI:

  1. In Nuxeo Studio, click on Automation > User Actions.
  2. Click on New and fill in the creation pop-up:
    • Feature ID: custom_validation_action
    • Label: Custom Validation
    • Category: Contextual ToolsThe user action is created. You now need to indicate when it should be available and link it to an automation chain.
  3. Edit the action properties:
    • Current user has one of the permissions: Edit
    • Current document has life cycle: project
  4. In the Action execution section, click on the Create button to create a new automation chain.

    If you are not already familiar with User Actions and Automation Chains, you might want to take a look at the How to Create an Automation Chain how-to first.

  5. Name the automation chain custom_validation_chain.
  6. Build the following chain and save.

    - Context.FetchDocument
    - Document.SetProperty:
        xpath: "dc:description"
        save: "true"
        value: Hello World
    - Document.CreateVersion:
        increment: Major
        saveDocument: "true"
    - Document.SetLifeCycle:
        value: approve
    - Seam.Refresh
    
  7. Deploy your changes on your Nuxeo Platform. Here is the action on a Project document.

    And this is the same document after clicking the action.

Adding a Button on the Edit Form

Adding a new button on the Edit form of a document takes the same configuration steps in Nuxeo Studio as in the previous section. The mandatory and specific elements to this use case are described below.

  • On the user action side, you must select the category Document Edition Form.
  • Your chain must hold the following two mandatory operations:

    - Seam.GetChangeableDocument
    - Seam.SaveDocumentInUI
    

This is what you get after deploying your Studio configuration:

Adding a Button on the Creation Form

You can also add buttons on the creation form. After you created the user action, create the automation chains and use the operation UI > Create Document in UI.

If you want to filter the button you are adding to the form only for a specific document type, you can use an advanced filtering condition on the user action:

#{navigationContext.getChangeableDocument().getType().equals("myDocumentType")}

Removing the Default Create or Edit Button

You can contribute an XML extension to remove the default button:

<extension point="actions" target="org.nuxeo.ecm.platform.actions.ActionService">
  <action id="CREATE_DOCUMENT">
    <filter-id>is_not_creating_for_type_T</filter-id>
  </action>
</extension>

<extension point="filters" target="org.nuxeo.ecm.platform.actions.ActionService">
  <filter id="is_not_creating_for_type_T">
    <rule grant="false">
      <condition>#{navigationContext.getChangeableDocument().getType().equals("T")}</condition>
    </rule>
  </filter>
</extension>

5 days ago manonlumeau NXDOC-1346-FT review screenshot
a year ago Solen Guitter 44
2 years ago Manon Lumeau 43 | replace "Write" by "Edit"
2 years ago Anahide Tchertchian 42
3 years ago Solen Guitter 41
3 years ago Solen Guitter 40
3 years ago Alain Escaffre 39
3 years ago Alain Escaffre 37
3 years ago Alain Escaffre 38
3 years ago Solen Guitter 36
3 years ago Solen Guitter 35
3 years ago Anahide Tchertchian 34
3 years ago Solen Guitter 33
3 years ago Solen Guitter 32
3 years ago Manon Lumeau 31
3 years ago Manon Lumeau 30
3 years ago Manon Lumeau 29
3 years ago Manon Lumeau 28
3 years ago Anahide Tchertchian 27
3 years ago Anahide Tchertchian 26
4 years ago Alain Escaffre 25
4 years ago Alain Escaffre 24
4 years ago Solen Guitter 23 | Fixed broken screenshots
4 years ago Solen Guitter 22 | Added excerpt
6 years ago Solen Guitter 20 | Added related tutorials
6 years ago Solen Guitter 21 | Migrated to Confluence 4.0
6 years ago Solen Guitter 19
6 years ago Solen Guitter 18
6 years ago Frédéric Vadon 17
6 years ago Frédéric Vadon 16
6 years ago Frédéric Vadon 15
6 years ago Frédéric Vadon 13
6 years ago Frédéric Vadon 14
6 years ago Solen Guitter 12
6 years ago Frédéric Vadon 11
6 years ago Frédéric Vadon 10
6 years ago Frédéric Vadon 9
6 years ago Frédéric Vadon 8
6 years ago Frédéric Vadon 7
6 years ago Frédéric Vadon 6
6 years ago Frédéric Vadon 5
6 years ago Frédéric Vadon 4
6 years ago Frédéric Vadon 3
6 years ago Frédéric Vadon 2
6 years ago Frédéric Vadon 1
History: Created by Frédéric Vadon