cancel
Showing results for 
Search instead for 
Did you mean: 

Aikau Simple Form Example

muralidharand
Star Contributor
Star Contributor
Hi All,
I created a very simple aikau form example.

http://www.codingfreaks.net/2015/03/aikau-form-example-for-simple-student.html



/* Here is the code of  student-form.get.js   */

/*
This page is used to render a simple form and POST the data to repository,
to create a new student folder under Document Library.
The Student model in described here ……..
Import the student model as described here….
*/

/* get the current site */
var site = page.url.templateArgs.site;
//Read the node reference of Document Library
var alfDestination = null;
var result = remote.call("/slingshot/doclib/container/"+site+"/documentLibrary");
if (result.status.code == status.STATUS_OK)
{
   alfDestination = JSON.parse(result).container.nodeRef;
}

//Create the form control for the student
var studentFormWidget = [     
    {
      name: "alfresco/forms/controls/DojoValidationTextBox",
      config: {
     label: "Student ID",
     name: "prop_student_StudentID"
      }
    },
    {
      name: "alfresco/forms/controls/DojoValidationTextBox",
      config: {
     label: "First Name",
     name: "prop_student_firstName"
      }
    },
    {
      name: "alfresco/forms/controls/DojoValidationTextBox",
      config: {
     label: "Last Name",
     name: "prop_student_lastName"    
      }
    },
    {
      name: "alfresco/forms/controls/DojoValidationTextBox",
      config: {
     label: "Email",
     name: "prop_student_email"
      }
    }
  ];  

 

//Create the form here
var form = {
   name: "alfresco/forms/Form",
   config: {
      showOkButton: true,
      okButtonLabel: "Save",  
      showCancelButton: false,
      cancelButtonLabel: "",
   //Specify the TOPIC here
      okButtonPublishTopic: "ALF_CRUD_CREATE",
      okButtonPublishGlobal: true,  
   okButtonPublishPayload: {
  //Specify the URL here to POST the data
        url: "api/type/student%3AstudentFolder/formprocessor",
  //To create the folder under document library, we need the documberLibrary nodeRer,So POST that too.
  alf_destination:alfDestination        
   },
     widgets: studentFormWidget
   }
};

//Add the form and services to the JSON MODEL
model.jsonModel = { widgets: [ form ],   services: ["alfresco/services/CrudService"] };





/* Details of   student-form.get.desc.xml   */
<webscript>
  <shortname>Student Form Example</shortname>
  <family>Aikau</family>
  <url>/studentForm</url>
</webscript>


/*   student-form.get.html.ftl   */
<@processJsonModel group="share"/>


14 REPLIES 14

Hi Satheesh,
Nowhere you've referred <strong> "ProductCreateListen.js" </strong> in your  <strong> "test-method.get.js" </strong>  file.

I would recommend, place your "ProductCreateListen.js" under "C:\Alfresco5\tomcat\webapps\share\js\alfresco\services" and refer the service javascript like the below,



model.jsonModel = {      
      services: ["alfresco/services/CrudService","alfresco/services/ProductCreateListen"]
      widgets:[title,anpForm]
}



Hope this helps you.

Please let me know, if you need any help on this.




I thought the alfSubcsribe will work without any reference mentioned in the calling file. It was my wrong assumption.

Now it works perfectly thanks again for your help Murali.

Is there any way I can show the actual error message occurred in the alert box, like in my case , I got the below error,
org.alfresco.service.cmr.repository.DuplicateChildNodeNameException: Duplicate child name not allowed

Can I show this in the alert window instead of just showing something wrong happened like "Sad now".

Thanks in Advance.

muralidharand
Star Contributor
Star Contributor
I found one example for File Upload option using Dojox.
http://mwilcox.dojotoolkit.org/dtk/dojox/form/tests/test_FileUploaderForm.html

I will try do an example in an Aikau way !

Hi Guys,

If you are doing a lot of Aikau development then this article might be useful:

https://docs.google.com/document/d/1q25jA5EQ5PRYekr8tpM3ELlwOQ8Ht3Ng6D4VWsKoZtY/pub

ddraper
World-Class Innovator
World-Class Innovator
There is also lots of information on Aikau form develop in the Aikau tutorial on GitHub: https://github.com/Alfresco/Aikau/blob/master/tutorial/chapters/Contents.md
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.