cancel
Showing results for 
Search instead for 
Did you mean: 

Send Email in menu Action

cybermakoki
Champ in-the-making
Champ in-the-making
Hi,

Anybody knows if there is a way to have the "send email" action in the document_browse_menu?

Actually, the only way to get to this action is by "Execute action" option…
8 REPLIES 8

dmihelj
Champ in-the-making
Champ in-the-making
Hi,

Anybody knows if there is a way to have the "send email" action in the document_browse_menu?

Actually, the only way to get to this action is by "Execute action" option…

Maybe this http://wiki.alfresco.com/wiki/Custom_Document_Library_Action will help you customize your actions. (Pay attention to instructions because they are different for pre- and after- 3.2 version of Alfresco).

cybermakoki
Champ in-the-making
Champ in-the-making
Thank you for the replay but I don't understand very well…

I'll try to explain better…

In the web-client-config-custom.xml I have this code:

 <action-handlers>
       <handler name="mail-attach" class="es.sic.handlers.MailAttachHandler" />
</action-handlers>



<action id="send">
         <label>Send email</label>         
         <image>/images/icons/letter.gif</image>         
         <action-listener>#{mail-attach.executeImpl}</action-listener>
      </action>

   <action-group id="document_browse_menu">                  
         <action idref="send" />
      </action-group>


And I'm getting this error:

javax.faces.el.ReferenceSyntaxException: Expression: #{mail-attach.executeImpl}
caused by:
org.apache.myfaces.el.ValueBindingImpl$NotVariableReferenceException: Parsed Expression of unsupported type for this operation. Expression class: org.apache.commons.el.BinaryOperatorExpression. Expression: '#{mail-attach.executeImpl}'

Maybe its because the action is a handler?

dmihelj
Champ in-the-making
Champ in-the-making
In which file do you have this code:

<action id="send">
         <label>Send email</label>        
         <image>/images/icons/letter.gif</image>        
         <action-listener>#{mail-attach.executeImpl}</action-listener>
      </action>

Maybe it would be better in web-client-config-actions.xml?

cybermakoki
Champ in-the-making
Champ in-the-making
I have all the custom actions in web-client-config-custom.xml and the only one with I'm having problemas is this one…

I'm having this error:

javax.faces.el.EvaluationException: Exception while invoking expression #{send.executeImpl}
caused by:
java.lang.NoSuchMethodException: es.sic.executer.MailAttachActionExecuter.executeImpl(javax.faces.event.ActionEvent)

dmihelj
Champ in-the-making
Champ in-the-making
I have all the custom actions in web-client-config-custom.xml and the only one with I'm having problemas is this one…

I'm having this error:

javax.faces.el.EvaluationException: Exception while invoking expression #{send.executeImpl}
caused by:
java.lang.NoSuchMethodException: es.sic.executer.MailAttachActionExecuter.executeImpl(javax.faces.event.ActionEvent)

Take a look at this thread if you find something useful http://forums.alfresco.com/en/viewtopic.php?f=48&t=20121.

cybermakoki
Champ in-the-making
Champ in-the-making
Hi,

Thank you for your reply but the problem persists…

I've been able to execute de MailAttachActionExecuter action, but that's not the fact, I need to execute this handler:

public class MailAttachHandler extends BaseActionHandler
{
   public static final String PROP_TO = "to";
   public static final String PROP_FROM = "from";
   public static final String PROP_MESSAGE = "message";
   public static final String PROP_SUBJECT = "subject";
   public static final String PROP_TEMPLATE = "template";
  
   public String getJSPPath()
   {
      return getJSPPath(MailAttachActionExecuter.NAME);
   }

   public void prepareForSave(Map<String, Serializable> actionProps,
         Map<String, Serializable> repoProps)
   {
      // get hold of the current wizard so we can extract some data from it
      BaseActionWizard wizard = (BaseActionWizard)Application.
            getWizardManager().getBean();
     
      // add the person(s) it's going to as a list of authorities
      List<String> recipients = new ArrayList<String>(wizard.getEmailRecipients().size());
      for (int i=0; i < wizard.getEmailRecipients().size(); i++)
      {
         RecipientWrapper wrapper = wizard.getEmailRecipients().get(i);
         recipients.add(wrapper.getAuthority());
      }
     
      repoProps.put(MailAttachActionExecuter.PARAM_TO_MANY, (Serializable)recipients);
     
      // add the actual email text to send
      repoProps.put(MailAttachActionExecuter.PARAM_TEXT, actionProps.get(PROP_MESSAGE));
         
      // add the subject for the email
      repoProps.put(MailAttachActionExecuter.PARAM_SUBJECT, actionProps.get(PROP_SUBJECT));
     
      // add the from address
      String from = Application.getClientConfig(FacesContext.getCurrentInstance()).getFromEmailAddress();
      repoProps.put(MailAttachActionExecuter.PARAM_FROM, from);
     
      // add the template if one was selected by the user
      if (wizard.getUsingTemplate() != null)
      {
         repoProps.put(MailAttachActionExecuter.PARAM_TEMPLATE, new NodeRef(Repository.getStoreRef(),
               wizard.getUsingTemplate()));
      }
   }

   public void prepareForEdit(Map<String, Serializable> actionProps,
         Map<String, Serializable> repoProps)
   {
      // get hold of the current wizard so we can extract some data from it
      BaseActionWizard wizard = (BaseActionWizard)Application.
            getWizardManager().getBean();
     
      String subject = (String)repoProps.get(MailAttachActionExecuter.PARAM_SUBJECT);
      actionProps.put(PROP_SUBJECT, subject);
     
      String message = (String)repoProps.get(MailAttachActionExecuter.PARAM_TEXT);
      actionProps.put(PROP_MESSAGE, message);
     
      // handle single email or multiple authority recipients
      String to = (String)repoProps.get(MailAttachActionExecuter.PARAM_TO);
      if (to != null)
      {
         actionProps.put(PROP_TO, to);
      }
      else
      {
         List<String> recipients = (List<String>)repoProps.get(MailAttachActionExecuter.PARAM_TO_MANY);
         if (recipients != null && recipients.size() != 0)
         {
            // rebuild the list of RecipientWrapper objects from the stored action
            for (String authority : recipients)
            {
               wizard.getEmailRecipients().add(
                     new RecipientWrapper(wizard.displayLabelForAuthority(authority),
                           authority));
            }
         }
      }
     
      NodeRef templateRef = (NodeRef)repoProps.get(MailAttachActionExecuter.PARAM_TEMPLATE);
      if (templateRef != null)
      {
         actionProps.put(PROP_TEMPLATE, templateRef.getId());
         wizard.setUsingTemplate(templateRef.getId());
      }
   }

   public String generateSummary(FacesContext context, IWizardBean wizard,
         Map<String, Serializable> actionProps)
   {
      BaseActionWizard actionWizard = (BaseActionWizard)wizard;
     
      String addresses = (String)actionProps.get(PROP_TO);
        
      if (addresses == null || addresses.length() == 0)
      {
         if (actionWizard.getEmailRecipients().size() != 0)
         {
            StringBuilder builder = new StringBuilder();
           
            for (int i=0; i < actionWizard.getEmailRecipients().size(); i++)
            {
               RecipientWrapper wrapper = actionWizard.getEmailRecipients().get(i);
               if (i != 0)
               {
                  builder.append(", ");
               }
               builder.append(wrapper.getName());
            }
           
            addresses = builder.toString();
         }
      }
     
      return MessageFormat.format(Application.getMessage(context, "action_mail_attach"),
            new Object[] {addresses});
   }
}

which paints the jsp that I need to send the email… and i don´t find the way to do that Smiley Sad the only way to execute this action is like this:

<action-handlers>
<handler name="mail" class="org.alfresco.web.bean.actions.handlers.MailAttachHandler" />
</action-handlers>

awelon
Champ in-the-making
Champ in-the-making
Hi everyone.

I have created the file 'my-action-context.xml' in path ''tomcat>/shared/classes/alfresco/extension/":

    <beans>
       <bean id="myAction"
             class="es.sia.alfresco.action.executer.MyActionExecuter"
             parent="actionexecuter">
          <property name="nodeService">
             <ref bean="NodeService" />
          </property>
       </bean>
       <bean id="extension.actionResourceBundles" parent="actionResourceBundles">
          <property name="resourceBundles">
             <list>
                <value>alfresco.extension.custodiaactionmessages</value>
             </list>
          </property>
       </bean>
    </beans>

But I get this error:

javax.faces.el.EvaluationException: Exception while invoking expression #{myAction.executeImpl}
caused by:
javax.faces.el.PropertyNotFoundException: Base is null: myAction

What's wrong? Where is my mistake?

poratable
Champ in-the-making
Champ in-the-making
It is really hard to digest new things!!  :cry:  I think its hard being an IT… any one with a working code? I also tried to try and try yet still the same error…