Pop Up Form in Alfresco Share

Alfresco share, which provides collaborative platform on top of Alfresco, and can also be used as an interface for Alfresco repository. The main building block for Alfresco share is the form. There is a form-service in the back end which handles the form rendition. As Alfresco share heavily relies on forms during customization, we always come across requirements where we need to create many Alfresco share forms. As far as normal forms, we want to design it very easily but sometimes we need to show those forms in popups after clicking.

The main steps involved in creating popup forms are as follows:

Step 1:

Configure action config in share-config-custom.xml

<action id="document-customaction" type="javascript" icon="customicon"

 label="actions.document.customaction">

      <!—param which indicate form needs to be open in popup   -->             

            <param name="function">onActionFormDialog</param>

     <!-- Additional parameters for onFormDialog function  -->

            <param name="itemKind">action</param>

            <param name="itemId">doc-tagging</param>

            <param name="mode">create</param>

            <param name="destination">{node.nodeRef}</param>

      <!--  params associated with the success and failure message of action   -->

            <param name="successMessage">message.customaction.success</param>

            <param name="failureMessage">message.customaction.failure</param>

 </action>

Step 2:

Add messages in property file custom.properties

actions.document.customaction =Custom Action

actions.mycompany.goToGoogle=Google Search

message.customaction.success=Custom action executed successfully.

message.customaction.failure=Couldn't complete custom action.

document-customaction.field.name=Name

document-customaction.field.address=address

Place it under <tomcat>/shared/classes/alfresco/messages

Step 3:

Register message related property file though custom-application-context.xml file

<beans>

   <!-- Add application extension messages -->

   <bean id="mycompany.resources" class="org.springframework.extensions.surf.util.ResourceBundleBootstrapComponent">

      <property name="resourceBundles">

         <list>

            <value>alfresco.messages.custom</value>

         </list>

      </property>

   </bean>

 </beans>

Place it under <tomcat>/shared/classes/alfresco/web-extension

Step 4:

Configure form in alfresco share which needs to be open in popup on click of action created in step1

&lt;config evaluator="string-compare" condition="<span style="color: #666666;">doc-tagging</span>"&gt;

        &lt;forms&gt;

            &lt;form&gt;

                &lt;field-visibility&gt;

                    &lt;show id="name"/&gt;

                    &lt;show id="address"/&gt;

                &lt;/field-visibility&gt;

                &lt;appearance&gt;

                    &lt;field id="name" label-id="document-customaction.field.name"&gt;

&lt;field id="address" label-id="document-customaction.field.address"&gt;

                     &lt;control template="/org/alfresco/components/form/controls/textarea.ftl" /&gt;                   

                    &lt;/field&gt;               

                &lt;/appearance&gt;

            &lt;/form&gt;

        &lt;/forms&gt;

    &lt;/config&gt;

Step 5:

Associate form created in step 2 with action created in step1

Form and actions are linked though action id i.e. document-customaction in this case. We just need to make sure form config has same condition attribute value as action id.

That’s it you are good to go restart your server. Login to alfresco share and click on your custom action you will be able to see popup with two fields called name and address.

Looking for quality Alfresco Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight

mitpatoliya

mitpatoliya

I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

6 Comments on Pop Up Form in Alfresco Share

  1. Clément says:

    Hi, I have a few questions.
    In the step 5 , how do I associate form created in step 2 with action created in step 1.
    And where do I click on the custom action ?
    Why condition=”doc-customaction” is different from id=”document-customaction” in your tuto since you said in step 5 “We just need to make sure form config has same condition attribute value as action id.” ?

    Thank you for your time

    Clément

    • mitpatoliya mitpatoliya says:

      Que: how do I associate form created in step 2 with action created in step 1?

      ANS: It will be associated through that form id only. I had edited post to match form id it was typo from my side sorry about it.

      Que:”where do I click on the custom action? “

      Ans : You can add created action in one of the action group and that will be visible along with other actions in same group. You can refer this article for more detail on custom actions.

  2. Clément says:

    Hello,
    thanks for your answer. My action is in the list, but now when I click on it, I have this exception in the console : org.alfresco.repo.forms.FormNotFoundException and the form is not displayed (error message in red) ?
    Do you know why ?

    • mitpatoliya mitpatoliya says:

      I have edited post please check itemID parameter value and form matching condition both should match.

  3. izodev says:

    Hello,
    Nice tuto , but I still have a question:
    Can I get a String generated in my Java custom action code to be displayed it in the form as an initialization value for some field ?
    Thank you for your response
    iZodev

    • mitpatoliya mitpatoliya says:

      But logically your action class will be called after form then how you will be able to show value set by action class? Am I missing something?

Leave a Reply

Your email address will not be published. Required fields are marked *


2 × = 2

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>