cancel
Showing results for 
Search instead for 
Did you mean: 

Display UI custom message in a workflow

uskiki85
Champ in-the-making
Champ in-the-making
Hi,

I would like to know if it is possible to display a custom message like "Workflow starting" ? or custom error message ?

Many thanks for your help

Regards

uskiki85

PS: My Workflow is used in Alfresco Share only
17 REPLIES 17

uskiki85
Champ in-the-making
Champ in-the-making
Any news ?

uskiki85
Champ in-the-making
Champ in-the-making
Any JIRA has been created ?

uskiki85
Champ in-the-making
Champ in-the-making
This topic has no success …

theoryoflinkin
Champ on-the-rise
Champ on-the-rise
So bad there is no given answer Smiley Sad

theoryoflinkin
Champ on-the-rise
Champ on-the-rise

muralidharand
Star Contributor
Star Contributor
We also had similar problem, later we extended the AlfrescoRuntimeException to our own custom class.
In this way,we're not displaying "org.Activiti.Exception…" and we're displaying own error message like 'com.quanticate….'.

<java>

public class CustomWorkflowException extends AlfrescoRuntimeException
{
   protected static final String UNKNOWN_MESSAGE = "CustomWorkflow.exception.unknown";
   protected static final String START_MESSAGE = "CustomWorkflow.exception.start";
  
   private static final long serialVersionUID = 2163551047437476248L;

   private String msgId;
   private String message;

   /**
    * Constructor
    *
    * @param msgId     the message id
    */
   public CustomWorkflowException(String msgId)
   {
       super(msgId);
       this.message = resolveMessage(msgId, null);
       this.msgId = msgId;
   }
  
   /**
    * Constructor
    *
    * @param msgId     the message id
    * @param cause     the exception cause
    */
   public CustomWorkflowException(String msgId, Throwable cause)
   {
       super(msgId, cause);
       this.message = resolveMessage(msgId, null);
       this.msgId = msgId;
   }
  
   /**
    * @return the msgId
    */
   public String getMsgId()
   {
       return msgId;
   }

   @Override
   public String getMessage()
   {
      return getLocalizedMessage();
   }

   @Override
   public String getLocalizedMessage()
   {
      return message;
   }

   @Override
   public String toString()
   {
      return I18NUtil.getMessage(START_MESSAGE) + " " + message;
   }

   /**
    * Resolves the message id to the localised string.
    * <p>
    * If a localised message can not be found then the message Id is
    * returned.
    *
    * @param messageId     the message Id
    * @param params        message parameters
    * @return              the localised message (or the message id if none found)
    */
   private static String resolveMessage(String messageId, Object[] params)
   {
       String message = I18NUtil.getMessage(messageId, params);
       if (message == null)
       {
           // If a localised string cannot be found then return the messageId
           message = messageId;
       }
      
       if (message == null || message.isEmpty())
       {
           // If there's no know message, pick the default unknown one
           message = I18NUtil.getMessage(UNKNOWN_MESSAGE);
       }
       return message;
   }
}

</java>

Hope this helps someone.

I need to include this java class inside Alfresco. How do it???. Thank

Hi,

You would need to register your class with the surf spring bean for it to be recognized.
Here is an example, you can always do a read up to understand more:


<beans>
<bean id="your-bean-id" parent="baseJavaScriptExtension" class="your.package.classname">
  <property name="extensionName">
   <value>method-name</value> //The method you want to expose to your alfresco.
  </property>
</bean>
</beans>


Give your file a name which ends with "-context.xml" and place it in the shared-extension folder.

Hope that helps.