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:
Configure action config in share-config-custom.xml
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
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
Configure form in alfresco share which needs to be open in popup on click of action created in step1
<config evaluator="string-compare" condition="<span style="color: #666666;">doc-tagging</span>"> <forms> <form> <field-visibility> <show id="name"/> <show id="address"/> </field-visibility> <appearance> <field id="name" label-id="document-customaction.field.name"> <field id="address" label-id="document-customaction.field.address"> <control template="/org/alfresco/components/form/controls/textarea.ftl" /> </field> </appearance> </form> </forms> </config>
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.