Monday, October 5, 2009

Creating a custom WCM form widget in Alfresco using Dojo -- part 3

The second implementation example of my creation of a new dojo form widget.

Please feel free to add any comments and suggestions.

Alfresco-based resources: - Details on incorporating widgets into an xsd - Details on creating XForms Widgets


Testing on Alfresco Labs 3.2
using the embedded dojo version 0.4.1
Application server: tomcat 6.0.18
OS: Ubuntu 9.04 x64
Linux kernel: 2.6.28-11-server
Using the WCM form created from Dr. Q's Web Form tutorial (, the "advanced-press-release" form

Implementation Example 2:

For the next example, I wanted to verify appended code in the xforms.js file. This time I will duplicate an existing javascript class and rename it.

Step 1: Update xforms.js
Step 1.1: Create a backup copy of /scripts/ajax/xforms.js
Step 1.2: In a modified copy of the file, copy the entire javascript class for ComboboxSelect:

alfresco.xforms.ComboboxSelect1 = alfresco.xforms.AbstractSelectWidget.extend({

Step 1.3: Paste the same block of code under the existing class; rename the class:

alfresco.xforms.ComboboxSelect2 = alfresco.xforms.AbstractSelectWidget.extend({

Step 1.3: Overwrite /scripts/ajax/xforms.js with the modified copy

Step 2: Update web-client-config-wcm.xml
Step 2.1: Update the widget created in the previous example to point to our new javascript class:

Step 2.2: Overwrite /WEB-INF/classes/alfresco/web-client-config-wcm.xml with the modified copy

Step 3: Restart Alfresco

Step 4: Verify update
Step 4.1: Open Form in web project
Step 4.2: Expand the Keyword section of the form
Step 4.3: Click on the + symbol to add a Keyword node to the form
Step 4.4: Verify that the form renders as a drop-down list with four or less elements, then we can be confident that the code is working.

*** Blocked: When I attempt to verify, I cannot get the widget to show in the form. Clicking on the + button does appear to add an element to the Keyword group, but that element is blank. Also, clicking on the + for the Keyword group causes all events to freeze on the form. None of the other + or - buttons on the form work at this point.

[updated 10/12/09]
*** Unblocked: Although I did restart the app server (i.e., tomcat) multiple times, alfresco didn't render the control. However, the next day the widget was working correctly. I believe it was a caching issue on the browser itself. It took a full shutdown & restart of my laptop (and subsequently, my browser) to re-cache all files.

My current explaination is that the xforms.js was cached on the local browser. So, when the xforms/chiba engine rendered the webform into our new javascript class, the included javascript file was outdated & didn't contain the new class.


[updated 10/12/09]
The following are some OOTB defined loggers:

#This is the logger for alfresco web scripts; specifically, the logger.log() function
#This is the logger for dojo widgets; specifically, the alfresco.log() function
#note that this logger alters the appearance of the web form by appending each widget's div id to the label

#Other loggers of note; I will attempt to update these as necessary
#An X11 server-side javascript debugger which will allow code breaks and stepping through code during run-time.

Existing JIRA issues regarding this process: -- states that the ootb xforms.js must be touched instead of having an external overriding copy as would be the usual method of overridding and extending.

No comments:

Post a Comment