cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a Custom Dialog: does not appear

nicolasraoul
Star Contributor
Star Contributor
Hello,

I want to create a dialog so I followed the tutorial:
http://wiki.alfresco.com/wiki/Adding_a_Custom_Dialog

I created the files and deployed them as explained by the tutorial, then I restarted Alfresco (3.2).
But the item action does not appear. Not even in the "More actions" menu.

No error in the log either (log4j: all debug).
What did I do wrong?

Here is the content of the ZIP file I uncompress in a fresh Alfresco 3.2's tomcat/webapps/alfresco:

> jsp
   > extension
      > add-aspect.jsp
> WEB-INF
   > lib
      > custom-dialog.jar

Here is the content of custom-dialog.jar:

> alfresco
   > extension
      > web-client-config-custom.xml
> META-INF
   > faces-config.xml
   > MANIFEST.MF
> org 
   > alfresco
      > sample
         > AddAspectDialog.class

add-aspect.jsp:

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>

<h:outputText value="#{msg.aspect}: " />
<h:selectOneMenu value="#{DialogManager.bean.aspect}">
   <f:selectItems value="#{RunActionWizard.testableAspects}" />
</h:selectOneMenu>

web-client-config-custom.xml (I am sure this file is read, because if I break the XML then Alfresco complains):

<alfresco-config>
   <config>
      <actions>
         <!– Launch Add Aspect Dialog –>
         <action id="add_aspect">
            <label>Add Aspect</label>
            <image>/images/icons/add.gif</image>
            <action>dialog:addAspect</action>
            <action-listener>#{BrowseBean.setupSpaceAction}</action-listener>
            <params>
               <param name="id">#{actionContext.id}</param>
            </params>
         </action>
         <!– Add action to more actions menu for each space –>
         <action-group id="space_browse_menu">
            <action idref="add_aspect" />
         </action-group>
      </actions>
      <dialogs>
         <dialog name="addAspect" page="/jsp/extension/add-aspect.jsp" managed-bean="AddAspectDialog"
                 icon="/images/icons/add_content_large.gif" title="Add Aspect"
                 description="Adds an aspect to the selected node" />
      </dialogs>
   </config>
</alfresco-config>

faces-config.xml (I am sure this file is read, because if I break the XML then Alfresco complains):

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
                              "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
   <managed-bean>
      <managed-bean-name>AddAspectDialog</managed-bean-name>
      <managed-bean-class>org.alfresco.sample.AddAspectDialog</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
      <managed-property>
         <property-name>nodeService</property-name>
         <value>#{NodeService}</value>
      </managed-property>
      <managed-property>
         <property-name>browseBean</property-name>
         <value>#{BrowseBean}</value>
      </managed-property>
   </managed-bean>
</faces-config>

MANIFEST.MF:

Manifest-Version: 1.0
Created-By: Nicolas
Class-Path: web-client-config-custom.xml

AddAspectDialog.java:

package org.alfresco.sample;

import javax.faces.context.FacesContext;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Repository;

public class AddAspectDialog extends BaseDialogBean
{
   protected String aspect;

   protected String finishImpl(FacesContext context, String outcome) throws Exception
   {
      // get the space the action will apply to
      NodeRef nodeRef = this.browseBean.getActionSpace().getNodeRef();

      // resolve the fully qualified aspect name
      QName aspectToAdd = Repository.resolveToQName(this.aspect);

      // add the aspect to the space
      getNodeService().addAspect(nodeRef, aspectToAdd, null);

      // return the default outcome
      return outcome;
   }

   public boolean getFinishButtonDisabled()
   {
      return false;
   }

   public String getAspect()
   {
      return aspect;
   }

   public void setAspect(String aspect)
   {
      this.aspect = aspect;
   }
}

Strangely, if instead of deploying this ZIP I just copy web-client-config-custom.xml to shared, then the item action appears (but of course it does not go further). However, I am sure this file is read in both cases, because if I break the XML then Alfresco complains.

Thanks a lot!
Nicolas.
1 REPLY 1

nicolasraoul
Star Contributor
Star Contributor
It was very easy: The action-group is space_browse_menu so the item action only appears for spaces… not for documents.
Sorry for the noise!