Written by The Jahia Team
   Estimated reading time:
7.2.x.x 7.3.x.x

How to add a redirect action in a context menu in edit mode?


As the GoToContentActionItem don't do a redirect to a content, a JSActionItem must be used. So follow steps are needed to define this Action:

  • Define a new JSActionItem and add it to the richt context menu in edit mode (in the spring definition of the module). In the example it is added in the content tab to the context menu:

<bean id="actionID" class="org.jahia.ajax.gwt.client.widget.toolbar.action.JSActionItem" >
        <property name="execute" value="executeFunction"/>
        <property name="init" value="initFunction"/>
        <property name="handleNewSelection" value="handleNewSelectionFunction"/>
        <property name="handleNewMainNodeLoaded" value="handleNewMainNodeLoadedFunction"/>
        <property name="selectionTarget" value="main"/> // main for single node selection

<bean id="toolbar.item.actionID" class="org.jahia.services.uicomponents.bean.toolbar.Item" >
        <property name="actionItem" ref="actionID"/>
        <property name="parent" value="contentTableContextMenuAnthracite"/>
  • Inject a custom java script file in the edit mode. This can be done in a module spring file like:

 <bean id="gwtResources" class="org.jahia.ajax.gwt.helper.ModuleGWTResources">
        <property name="javascriptResources">

You can store the js file also in the module, so the path would look like: /modules/yourModuleName/javascript/jsFile.js


  • Inside the js file, you have to define the needed js methods (which are configured in the JSActionItem in step1:

window.InitFunction = (i) => {

window.handleNewSelectionFunction = (path) => {


window.handleNewMainNodeLoadedFunction = (path) => {

window.ExecuteFunction = (path) => {
    //handle redirection 

 As example for the window.ExecuteFunction you can do there a location.replace to an servlet or any other url which is needed. The path parameter specify the current content path (where the action is executed).

Related links