03-07-2015 12:21 PM
/* 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"/>
03-12-2015 04:03 AM
var result = remote.call("/slingshot/doclib/container/"+site+"/documentLibrary/Product Library");
var result = remote.call("/slingshot/doclib/container/"+site+"/documentLibrary/cm:Product Library");
java.lang.ClassCastException: org.json.JSONObject$Null cannot be cast to java.lang.String
03-12-2015 05:02 AM
03-12-2015 05:33 AM
var result = remote.call("/slingshot/doclib2/doclist/file/site/"+site+"/documentLibrary/Product");
if (result.status.code == status.STATUS_OK)
{
alfDestination = JSON.parse(result).metadata.parent.nodeRef;
}
03-13-2015 01:00 AM
var result = remote.call("/slingshot/doclib2/doclist/file/site/"+site+"/documentLibrary/Product%20Library"); //%20 for space
if (result.status.code == status.STATUS_OK)
{
alfDestination = JSON.parse(result).metadata.parent.nodeRef;
}
//Create the form control for the productType
var productTypeWidget = [
{
name: "alfresco/forms/controls/DojoValidationTextBox",
config: {
label: "Product Name",
name: "prop_cm_name"
}
},
{
name: "alfresco/forms/controls/DojoValidationTextBox",
config: {
label: "Product Title",
name: "prop_cm_title"
}
},
{
name: "alfresco/forms/controls/DojoValidationTextBox",
config: {
label: "Product Description",
name: "prop_cm_description"
}
},
{
name: "alfresco/forms/controls/DojoValidationTextBox",
config: {
label: "Product Prefix",
name: "prop_hccm_prefix" //This is the custom property
}
}
];
2015-03-12 23:39:43,605 [DEBUG] org.alfresco.repo.jscript.ScriptLogger.debug(ScriptLogger.java:50) org.alfresco.service.cmr.repository.DuplicateChildNodeNameException: Duplicate child name not allowed: Banner Small
2015-03-12 23:39:43,606 [DEBUG] org.alfresco.repo.jscript.ScriptLogger.debug(ScriptLogger.java:50) Returning 500 status code
Is there any way I can show the user an error message in case of creation failure.var result = remote.call("/slingshot/doclib/container/"+site+"/documentLibrary");
if (result.status.code == status.STATUS_OK)
{
alfDestination = JSON.parse(result).container.nodeRef;
}
var result = remote.call("/slingshot/doclib2/doclist/file/site/"+site+"/documentLibrary/Product%20Library");
if (result.status.code == status.STATUS_OK)
{
alfDestination = JSON.parse(result).metadata.parent.nodeRef;
}
03-13-2015 07:21 AM
03-16-2015 03:13 AM
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,
alfResponseTopic :"PRODUCT_CREATE"
}
this.alfSubscribe("PRODUCT_CREATE_SUCCESS", lang.hitch(this, this.showSuccessResponse));
this.alfSubscribe("PRODUCT_CREATE_FAILURE", lang.hitch(this, this.showFailureResponse));
showSuccessResponse: function __showSuccessResponse(payload) {
alert('Happy now');
},
showFailureResponse: function __showFailureResponse(payload) {
alert('Sad now');
}
03-26-2015 06:21 AM
alfResponseTopic :"PRODUCT_CREATE"
in my custom form and I created a Widget to subscribe the topic, but it is not getting called for both success and failure, can you please guide me.alfResponseTopic
's value to "PRODUCT_CREATE_SUCCESS" AND "PRODUCT_CREATE_FAILURE"
, and tried, but still no luck.
define([ "dojo/_base/declare", "dijit/_WidgetBase", "alfresco/core/Core",
"dojo/_base/lang" ], function(declare, _Widget, Core, lang) {
return declare([ _Widget, Core ], {
postCreate : function example_widget_productCreateListen__postCreate() {
this.alfSubscribe("PRODUCT_CREATE_SUCCESS", lang.hitch(this,
this.showSuccessResponse));
this.alfSubscribe("PRODUCT_CREATE_FAILURE", lang.hitch(this,
this.showFailureResponse));
},
showSuccessResponse : function __showSuccessResponse(payload) {
alert('Happy now');
},
showFailureResponse : function __showFailureResponse(payload) {
alert('Sad now');
}
});
});
03-27-2015 06:42 AM
03-27-2015 08:35 AM
/* test-method.get.js */
var site = "retail-channels-product-management";
//Read the node reference of Product Library under Document Library
var alfDestination = null;
//Derived based on the URI "/slingshot/doclib2/doclist/{type}/site/{site}/{container}/{path}"
var result = remote.call("/slingshot/doclib2/doclist/file/site/" + site
+ "/documentLibrary/Test");
if (result.status.code == status.STATUS_OK) {
alfDestination = JSON.parse(result).metadata.parent.nodeRef;
};
var title = {
id : "SET_PAGE_TITLE",
name : "alfresco/header/SetTitle",
config : {
title : "Custom Test Page"
}
};
var productName = {
name:"alfresco/forms/controls/DojoValidationTextBox",
config: {
label:"Product Name",
name:"prop_cm_name"
}
};
var productTitle = {
name:"alfresco/forms/controls/DojoValidationTextBox",
config: {
label:"Product Title",
name:"prop_cm_title"
}
};
var productDescription = {
name:"alfresco/forms/controls/DojoValidationTextBox",
config: {
label:"Product Description",
name:"prop_cm_description"
}
};
var anpForm = {
name : "alfresco/forms/Form",
config:{
okButtonLabel : "Create",
okButtonPublishTopic : "ALF_CRUD_CREATE",
okButtonPublishGlobal : true,
okButtonPublishPayload : {
//Specify the URL here to POST the data
//Dereived based on the URI "/api/{item_kind}/{item_id}/formprocessor"
url : "api/type/cm%3Afolder/formprocessor",
//To create the folder under product Library of document library, we need the productLibrary nodeRer,So POST that too.
alf_destination : alfDestination,
alfResponseTopic :"PRODUCT_CREATE_SUCCESS" //tried with "PRODUCT_CREATE" initially and tried with "PRODUCT_CREATE_SUCCESS"
},
widgets:[]
}
};
anpForm.config.widgets.push(productName,productTitle,productDescription);
model.jsonModel = {
services:["alfresco/services/CrudService"],
widgets:[title,anpForm]
}
define([ "dojo/_base/declare", "dijit/_WidgetBase", "alfresco/core/Core",
"dojo/_base/lang" ], function(declare, _Widget, Core, lang) {
return declare([ _Widget, Core ], {
postCreate : function example_widget_productCreateListen__postCreate() {
this.alfSubscribe("PRODUCT_CREATE_SUCCESS", lang.hitch(this,
this.showSuccessResponse));
this.alfSubscribe("PRODUCT_CREATE_FAILURE", lang.hitch(this,
this.showFailureResponse));
},
showSuccessResponse : function __showSuccessResponse(payload) {
alert('Happy now');
},
showFailureResponse : function __showFailureResponse(payload) {
alert('Sad now');
}
});
});
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.