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
<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>
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!
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
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.
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.
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 ?
I have edited post please check itemID parameter value and form matching condition both should match.
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
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?
I have two questions about step 4.
1. What is the name of the file this content goes in?
2. Where, in my eclipse project, do I put that file?
Thanks,
Bob