0% found this document useful (0 votes)
21 views

Form Management Technical Doc (Jquery Plugin) : Initiating The Form Using Aspects

This document summarizes a jQuery plugin for managing forms in Alfresco. It discusses including the necessary scripts, initializing forms using aspects or profiles retrieved from webscript services, and the options, events, and methods available for the form plugin. Key options include aspects, profile, and custom properties for initializing the form. Events allow specifying callbacks for form completion, saving, and loading. Methods allow initializing the plugin, loading node data into fields, saving form data to nodes, and more.

Uploaded by

shamsoudin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Form Management Technical Doc (Jquery Plugin) : Initiating The Form Using Aspects

This document summarizes a jQuery plugin for managing forms in Alfresco. It discusses including the necessary scripts, initializing forms using aspects or profiles retrieved from webscript services, and the options, events, and methods available for the form plugin. Key options include aspects, profile, and custom properties for initializing the form. Events allow specifying callbacks for form completion, saving, and loading. Methods allow initializing the plugin, loading node data into fields, saving form data to nodes, and more.

Uploaded by

shamsoudin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Form Management Technical Doc (jQuery Plugin)

Here are the essential scripts:

<!--You need to download and reference jquery -->


<script type="text/javascript" src="/share/js/jquery/jquery.js"></script>
<script type="text/javascript" src="/share/js/jquery/jquery-ui.js"></script>
<script src="/alfresco/scripts/form-builder/jquery.live.js" type="text/javascript"></script>

<!--Form Management scripts -->


<script src="/alfresco/scripts/form-builder/validation.js" type="text/javascript"></script>
<script src="/alfresco/scripts/form-builder/form.jquery.js" type="text/javascript"></script>

Initiating the form using Aspects


Let’s say you are developing an application and you KNOW what aspects are required. You can
easily display a form to the user by knowing these aspects up front with very little code.

Webscript Service
In your get.js file call the FM service to get the aspect objects you want, then, expose them to the
client side via the model.

var myAspectList = “dmo_aspect~dmo_example”;


model.aspectObj = remote.call(“model/aspects/aspecttoproperty?aspects=” + myAspectList);

Source Code HTML


<div class=”formContainerStage'”></div>

Source Code JavaScript


var aspectObj = ${ aspectObj!}

$('.formContainerStage').form({
'aspects': aspectObj
});

Initiating the form using Profiles


The simplest way to use profiles is to have an aspect that uses a dropdown list with a profile
assigned to it. The FM Plugin will automatically find this relationship and show/hide the profiles
based upon the users selection.

There are many different ways the FM Form can be initiated and used. Take a look at the webscripts
in the form builder and previewer. I have made the FM Module really flexible so you should be able
to do what you need.

If there is something you would like to see in this Module, let me know!
Options

Parameter Default Type Description Version


Released
aspects [] <Array> An array of aspects given from the 1.0.1
FM Services (See FM Get Aspect
Service)

profile Null <Object> Profile object taken from FM 1.0.1


Services (See FM Get Profile Service)

handler ‘.handler’ <String> Element class name used for 1.0.1


dynamic dropdown menus (Only
used if you want to use a dropdown list
OUTSIDE of the FM Form)

isSearch False <Boolean> This determines whether or not the 1.0.1


form builder should enforce
required validation. For search, you
should be able to search on any field
individually

postUrl ‘’ <String> The URL used by the plugin to POST 1.0.1


the metadata JSON Object
useShareProxy True <Boolean> The AJAX URL references used 1.0.1
internally by the plugin can be called
via Share or Alfresco webscripts.
This trigger allows us to state where
we are coming from e.g. Share will
use /share/proxy/alfresco/<Path to
Webscript> and Alfresco will use
/alfresco/wcs/< Path to Webscript>

customProperties Null <Object> The custom properties object allows 1.0.1


us to enforce specific titles and
descriptions on the main form
header, for example:

'customProperites' : {
'title': "My Custom Title",
'description': "Example description
custom."
}

This will override any aspect or profile


title stored.
readonly False <Boolean> If set to true, the templates used to 1.0.3
render form fields will be read only
and styled to look like labels (Each
field has a class name of “fm-
readonly” so you can use your own
styles.

Events
Parameter Default Purpose Version Released
onComplete Null When the form has been 1.0.1
drawn, the onComplete
function passed to the
plugin will be executed.
onSaveComplete Null When the form data has 1.0.1
been saved, the
onSaveComplete function
passed to the plugin will
be executed
onLoadComplete Null When the form data has 1.0.4
been loaded into its
respective fields, the
onLoadComplete function
passed to the plugin will
be executed

Methods
Function Parameters Purpose Version Released
Init(options) Options: (see Initiates the plugin and 1.0.1
initialization draws a form based on the
parameters above) given aspect(s), or profile

loadPropertiesToFields( nodeObj<Object>: Used by method loadNode 1.0.1


nodeObj) Node properties in this function will take a
JSON. Object taken node JSON object and
from webscript call push its values into the
node.toJSON(); correct fields in the form
that is already rendered.

This is good for forcing


defaults if you create your
own object 

loadNode (uid, readonly, uid<String>: ROADMAP ITEM 1.0.1


callback) Alfresco node uid This method takes a UID
and gets a JSON
readonly<Boolean>: representation of a node
Allows us to force from alfresco. It then
loading values into executes the
readonly loadPropertiesToFields
method.
callback<function>:
Local Callback for the The properties of the UID
individual call. Init save given are cached on in
callback can be used as HTML for reuse later on.
a global call for all save
functions

save(uid, optionalMoveId, uid<String>/<Array>: This method loops through 1.0.1


callback) Alfresco node uid. the current form and
If an array of uid's are creates a key value pair of
passed to this alfresco property names
function. Each node in and values to save.
the array will saved
with the form JSON save object is sent to
metadata the backend to apply the
metadata to the given
optionalMoveId node reference.
<String>:
Alfresco node uid of a
space to move the file
to after it saved.

callback<function>:
Local Callback for the
individual call. Init save
callback can be used as
a global call for all save
functions

You might also like