0
Alfresco Forms Part 2: Deep Dive<br />1<br />Gavin Cornwell<br />Services Team Lead, Alfresco<br />twitter: @gcornwell<br />
Agenda<br />2<br /><ul><li>Architecture</li></ul> Form Service<br /> Form UI Component<br /> Forms Runtime<br /><ul><li>De...
Debugging
Q & A</li></li></ul><li>Architecture<br />3<br />
Form Service Overview<br />4<br />
Form Service – Java API<br />5<br /><ul><li>Item</li></ul>Kind<br />Id<br /><ul><li>Form object returned</li></ul>public F...
Form Service – FormProcessor<br />6<br /><ul><li>Matched by Item Kind
FilteredFormProcessor
Node, Type, Workflow & Task implementations</li></ul>public Form generate(Item item, List<String> fields, List<String> for...
Form Service – Form Filter<br />7<br />Similar to Servlet Filters<br />Recommended way to customise<br />Each FormProcesso...
Form Service – Form Filter<br />8<br />public void beforeGenerate(ItemType item, List<String> fields, List<String> forcedF...
REST API /api/formdefinitions Request<br />9<br />POST /api/formdefinitions<br />Returns form definition<br />JSON passed ...
Form UI Component Overview<br />10<br />
Form UI Component – Web Script<br />11<br />Java backed UI Web Script as of 3.4<br /><@region id=“metadata" scope="templat...
Form UI Component Options<br />12<br /><ul><li>itemKind
itemId
formId
mode
destination
redirect
submitType</li></ul>json<br />multipart (default)<br />urlencoded<br />method<br />submissionUrl<br />showSubmitButton<br ...
Form UI Component Event Sequence<br />13<br />Asks ConfigService for list of fields for item<br />Sends list of fields (if...
Form UI Component FreeMarker<br />14<br /><#if form.xxxTemplate?? && form.mode == ”xxx"><br />   <#include "${form.xxxTemp...
Forms Runtime JavaScript Library<br />15<br /><ul><li>YUI Based
Upcoming SlideShare
Loading in...5
×

Alfresco Forms Service Deep Dive

3,940

Published on

This session will examine each element of the Forms Service Architecture in detail, from the server-side FormProcessor & Form Filters to the client-side Form UI component and Forms Runtime JavaScript library. You will learn how to use the form services in your own applications, discuss configuration options and work through several customization examples demonstrating how to implement custom controls, form templates and form filters.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,940
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
97
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • There are a few more methods with a Map&lt;String, Object&gt; parameter representing a context, not shown for brevity and not used yet.
  • There is also a Map&lt;String, Object&gt; parameter representing a context, not shown for brevity and not used yet
  • Transcript of "Alfresco Forms Service Deep Dive"

    1. 1. Alfresco Forms Part 2: Deep Dive<br />1<br />Gavin Cornwell<br />Services Team Lead, Alfresco<br />twitter: @gcornwell<br />
    2. 2. Agenda<br />2<br /><ul><li>Architecture</li></ul> Form Service<br /> Form UI Component<br /> Forms Runtime<br /><ul><li>Demo (Customization)
    3. 3. Debugging
    4. 4. Q & A</li></li></ul><li>Architecture<br />3<br />
    5. 5. Form Service Overview<br />4<br />
    6. 6. Form Service – Java API<br />5<br /><ul><li>Item</li></ul>Kind<br />Id<br /><ul><li>Form object returned</li></ul>public Form getForm(Item item);<br />public Form getForm(Item item, List<String> fields);<br />public Form getForm(Item item, List<String> fields, List<String> forcedFields);<br />public Object saveForm(Item item, FormData data);<br />
    7. 7. Form Service – FormProcessor<br />6<br /><ul><li>Matched by Item Kind
    8. 8. FilteredFormProcessor
    9. 9. Node, Type, Workflow & Task implementations</li></ul>public Form generate(Item item, List<String> fields, List<String> forcedFields);<br />public Object persist(Item item, FormData data);<br />public booleanisApplicable(Item item);<br />public booleanisActive();<br />
    10. 10. Form Service – Form Filter<br />7<br />Similar to Servlet Filters<br />Recommended way to customise<br />Each FormProcessor has a FilterRegistry<br />Filter is called for every item<br />Do conditional checks in your filter<br />Examples in RM<br />
    11. 11. Form Service – Form Filter<br />8<br />public void beforeGenerate(ItemType item, List<String> fields, List<String> forcedFields, Form form);<br />public void afterGenerate(ItemType item, List<String> fields, List<String> forcedFields, Form form);<br />public void beforePersist(ItemType item, FormData data);<br />public void afterPersist(ItemType item, FormData data, PersistTypepersistedObject);<br />public booleanisActive();<br />
    12. 12. REST API /api/formdefinitions Request<br />9<br />POST /api/formdefinitions<br />Returns form definition<br />JSON passed in<br />JSON response<br />POST /api/formprocessor<br />Persists form data<br />JSON or multipart/form-data passed in<br />Response matches request type<br />Examples of JSON will be seen in the demo<br />
    13. 13. Form UI Component Overview<br />10<br />
    14. 14. Form UI Component – Web Script<br />11<br />Java backed UI Web Script as of 3.4<br /><@region id=“metadata" scope="template” protected=true /><br /><component><br /> <region-id>metadata</region-id><br /> <url>/components/form</url><br /> <properties><br /> <itemKind>node</itemKind><br /> <itemId>{nodeRef}</itemId><br /> <mode>edit</mode><br /> <submitType>json</submitType><br /> </properties><br /></component><br />
    15. 15. Form UI Component Options<br />12<br /><ul><li>itemKind
    16. 16. itemId
    17. 17. formId
    18. 18. mode
    19. 19. destination
    20. 20. redirect
    21. 21. submitType</li></ul>json<br />multipart (default)<br />urlencoded<br />method<br />submissionUrl<br />showSubmitButton<br />showCancelButton<br />showResetButton<br />showCaption<br />
    22. 22. Form UI Component Event Sequence<br />13<br />Asks ConfigService for list of fields for item<br />Sends list of fields (if any) to FormService<br />FormService response “combined” with configuration for item<br />“form” model is set (demo will show example)<br />FreeMarker template is rendered<br />Custom template used if configured<br />FTL for each control is #included<br />Forms Runtime initialisation code generated<br />
    23. 23. Form UI Component FreeMarker<br />14<br /><#if form.xxxTemplate?? && form.mode == ”xxx"><br /> <#include "${form.xxxTemplate}" /><br /><#else><br /> <#if formUI == "true"><br /> <@formLib.renderFormsRuntimeformId=formId /><br /> </#if><br /> <@formLib.renderFormContainerformId=formId><br /> <#list form.structure as item><br /> <#if item.kind == "set"><br /> <@formLib.renderSet set=item /><br /> <#else><br /> <@formLib.renderField field=form.fields[item.id] /><br /> </#if><br /> </#list><br /> </@><br /></#if><br />
    24. 24. Forms Runtime JavaScript Library<br />15<br /><ul><li>YUI Based
    25. 25. Manages form validation</li></ul>Register validation handlers<br />Dynamically adjusts the submit button state<br /><ul><li>Handles form submission</li></ul>POSTing data as JSON<br />AJAX submission<br />Callbacks for custom processing before & after submission<br /><ul><li>Can be used standalone</li></li></ul><li>Form Generation<br />16<br />
    26. 26. Form Persistence<br />17<br />
    27. 27. Customisation (Demo)<br />18<br /><ul><li>Configure custom type
    28. 28. Create a custom form control (YUI Slider)
    29. 29. Create a custom form template (tabbed form)
    30. 30. Implement a Form Filter</li></ul>afterGenerate<br />beforePersist<br /><ul><li>Debugging Tips</li></ul>Forms Development Kit (FDK)<br />
    31. 31. Debugging<br />19<br /><ul><li>Log4J settings</li></ul>org.alfresco.repo.forms=debug<br />org.alfresco.web.config.forms=debug<br />org.alfresco.web.scripts.forms=debug<br /><ul><li>Forms Development Kit (FDK)</li></ul>Form Console (/<app>/fdk/form-console)<br />Debug control & template (dumps model)<br /><ul><li>Cntrl, Cntrl, Shift, Shift
    32. 32. Eclipse</li></ul>FormUIGet for UI<br />FilteredFormProcessor for server<br /><ul><li>Spring Surf Developer Tools</li></li></ul><li>Roadmap<br />20<br /><ul><li>Reduce the volume of configuration required
    33. 33. Repeating field and group support
    34. 34. Upload support
    35. 35. Improve association support
    36. 36. Improve error handling (validation feedback)
    37. 37. Dependent field support
    38. 38. Form level validation
    39. 39. More controls</li></li></ul><li>Q & A<br />21<br />
    40. 40. Learn More<br />22<br />wiki.alfresco.com/wiki/Forms<br />blogs.alfresco.com/wp/gavinc/<br />
    41. 41. Appendix – Demo Config<br />23<br /><config evaluator="node-type" condition="devcon:session"><br /> <forms><br /> <form><br /> <field-visibility><br /> <show id="devcon:code" /><br /> <show id="cm:name" /><br /> <show id="devcon:abstract" /><br /> <show id="devcon:presenter" /><br /> <show id="devcon:duration” /><br /> <show id="daysAway" /> <br /> <show id="devcon:when" /><br /> <show id="devcon:level" /><br /> <show id="devcon:prerequisites" /><br /> <show id="devcon:approved" /><br /> <show id="devcon:rating" /><br /> </field-visibility><br /> <edit-form template="/devcon/tab-edit-form.ftl" /> <br /> <appearance><br /> <set id="" label="Details" /><br /> <set id="time" label="Time" /><br /> <set id="feedback" label-id="set.label.feedback" /><br /> <field id="devcon:approved" set="feedback" /><br /> <field id="devcon:rating" set="feedback"><br /> <control template="/devcon/progress.ftl" /><br /> </field><br /> <field id="devcon:when" set="time" /><br /> <field id="devcon:duration" set="time" /><br /> <field id="daysAway" set="time" /><br /> </appearance><br /> </form><br /> </forms><br /></config><br />
    42. 42. Working Example<br />24<br /><ul><li>The working example will be made available in the next few weeks on my blog at http://blogs.alfresco.com/wp/gavinc
    43. 43. In the meantime have a look at the FDK for more examples</li>
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×