04-06-2015 01:33 AM
//My Custom Model defintion
<type name="hccm:productTypeFolder">
<title>Product Type Folder</title>
<parent>cm:folder</parent>
<properties>
<property name="hccm:prefix">
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="hccm:imageLibraryList">
<type>d:text</type>
<mandatory>false</mandatory>
<multiple>true</multiple>
</property>
</properties>
</type>
//My AIKAU Form
//I have not given the complete form here, just have shown the required widgets alone,
//imageLibraryPicker widget configuration
var imageLibraryPicker = {
name : "alfresco/forms/controls/SimplePicker",
config : {
label : "Pick Image Libraries",
description : "This is a simple picker publishes a request to get data to display",
visibilityConfig : {
initialValue : false,
rules : [ {
targetId : "SHOW_OTHER_FIELDS",
is : [ true ]
} ]
},
name : "prop_hccm_imageLibraryList",
noItemsMessage: "No Libraries Available!",
loadDataPublishTopic : "ALF_CRUD_GET_ALL",
loadDataPublishPayload : {
url : "retrieve-library-list?retrieve=Image%20Library"
},
itemsProperty : "imagesLibraryList",
itemKey : "prop_cm_name",
propertyToRender : "prop_cm_name",
availableItemsLabel : "Available",
pickedItemsLabel : "Currently Selected"
}
};
//showOrHideCheckBox widgets configuration
var showOrHideCheckBox = {
name : "alfresco/forms/controls/CheckBox",
config : {
fieldId : "SHOW_OTHER_FIELDS",
label : "Want to Associate Image Libraries?",
description : "Check this box to associate Image Libraries to this Product Type",
name : "extra_info",
value : false
}
};
// Create the form here
var addNewProductForm = {
name : "alfresco/forms/Form",
config : {
showOkButton : true,
okButtonLabel : "Create",
showCancelButton : false,
cancelButtonLabel : "Cancel",
// Specify the TOPIC here
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/hccm%3AproductTypeFolder/formprocessor",
// To create the folder under product Library of document library,
// we need the productLibrary nodeRer,So POST that too.
alf_destination : alfDestination,
alfResponseTopic : "HC_PRODUCT_CREATE"
},
widgets : [
{
name : "alfresco/forms/ControlRow",
config : {
title : "",
description : "Mandatory Details.",
widgets : [ productName, productPrefix ]
}
},
{
name : "alfresco/forms/ControlRow",
config : {
title : "",
description : "If you want to associate Image Libraries for this Product Type, you can do here.",
widgets : [ showOrHideCheckBox ]
}
},imageLibraryPicker]
}
};
model.jsonModel = {
services : [ "alfresco/services/CrudService",
"alfresco/services/DialogService",
"hc/widgets/response/ProductCreateListen" ],
widgets : [ {
name : "alfresco/layout/VerticalWidgets",
config : {
widgetMarginTop : "10",
widgetMarginBottom : "10",
widgets : [{
name : "alfresco/layout/HorizontalWidgets",
config : {
widgetMarginLeft : "10",
widgetMarginRight : "10",
widgets : [ {
name : "alfresco/layout/ClassicWindow",
widthPx : "550",
config : {
title : "Add New Product Type Page",
widgets : [ {
name : "alfresco/layout/TitleDescriptionAndContent",
config : {
title : "Create Product Type",
description : "This is the Page for Creating New Product Types.",
widgets : [ addNewProductForm ]
}
} ]
}
} ]
}
} ]
}
} ]
};
//Error I see in the logs when I submit this form
2015-04-06 00:06:51,760 [DEBUG] org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:437) form.post.json.js Start
2015-04-06 00:06:51,762 [DEBUG] org.alfresco.repo.jscript.ScriptLogger.debug(ScriptLogger.java:50) json form submission for item:
2015-04-06 00:06:51,762 [DEBUG] org.alfresco.repo.jscript.ScriptLogger.debug(ScriptLogger.java:50) kind = type
2015-04-06 00:06:51,763 [DEBUG] org.alfresco.repo.jscript.ScriptLogger.debug(ScriptLogger.java:50) id = hccm:productTypeFolder
2015-04-06 00:06:51,860 [DEBUG] org.alfresco.repo.jscript.ScriptLogger.debug(ScriptLogger.java:50) java.lang.IllegalArgumentException: Node properties must be fully serializable, including values contained in collections.
Property: Name: {http://www.mycompany.com/model/content/1.0}imageLibraryList
Title: null
Description: null
Default Value: null
DataType Name: {http://www.alfresco.org/model/dictionary/1.0}text
ContainerClass Name: {http://www.mycompany.com/model/content/1.0}productTypeFolder
isMultiValued: true
isMandatory: false
isMandatoryEnforced: false
isProtected: false
isIndexed: true
isStoredInIndex: false
isIndexedAtomically: true
indexTokenisationMode: TRUE
Index: 0
Value: {"index":0,"prop_cm_name":"Images1","alfTopic":"4137d6fa-4ee5-4673-8657-5e707916c89aALF_ITEM_SELECTED","isLastItem":false}
2015-04-06 00:06:51,861 [DEBUG] org.alfresco.repo.jscript.ScriptLogger.debug(ScriptLogger.java:50) Returning 500 status code
2015-04-06 00:06:51,861 [DEBUG] org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:535) form.post.json.js End 101 ms
04-15-2015 05:21 AM
04-16-2015 09:21 AM
04-29-2015 02:25 PM
05-04-2015 05:28 AM
//My custom Service
define([ "dojo/_base/declare", "alfresco/core/Core", "dojo/_base/lang",
"alfresco/core/CoreXhr", "service/constants/Default","alfresco/dialogs/AlfDialog","hc/widgets/topics/_TopicsMixin" ], function(
declare, Core, lang, CoreXhr, AlfConstants, AlfDialog, _TopicsMixin) {
return declare([ Core, CoreXhr, _TopicsMixin ], {
constructor : function hc_widgets__constructor(args) {
lang.mixin(this, args);
this.alfSubscribe(this.ProductCreateTopic, lang.hitch(this,
this.createProductType)); //ProductCreateTopic has been mapped to the custom topic that I publish
},
createProductType : function hc_widgets__createProductType(payload) {
this.serviceXhr({
url : AlfConstants.PROXY_URI + "manage-product-library/" +payload.prop_cm_name+"?action=create",
method : "POST",
data : {
prop_cm_name : payload.prop_cm_name,
prop_hccm_prefix : payload.prop_hccm_prefix,
prop_cm_title : payload.prop_cm_title,
prop_cm_description : payload.prop_cm_description,
prop_hccm_imageLibraryList : payload.prop_hccm_imageLibraryList,
prop_hccm_backgroundImageLibraryList : payload.prop_hccm_backgroundImageLibraryList,
prop_hccm_stockImageLibraryList : payload.prop_hccm_stockImageLibraryList,
prop_hccm_photoImageLibraryList : payload.prop_hccm_photoImageLibraryList,
prop_hccm_graphicsImageLibraryList : payload.prop_hccm_graphicsImageLibraryList
},
successCallback: this.onSuccessCreate,
failureCallback: this.onFailureCreate,
callbackScope: this
});
}
});
});
//My Custom JavaBacked Webscript,
Portion of logic to post the data,
if(action != null && action.equalsIgnoreCase("create")){
logger.warn("Going to "+action+" the product type : "+ productType);
//This actually generates the JSON Object.
jsonObject = HCCommonUtils.generateJSONObject(req);
try {
//This Generates the productMap.
Map<QName, Serializable> productMap = generateProductMap();
try {
if (productMap != null) {
//Creating the Actual Node. //QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "name") is no way related here, but still it is mandatory so giving a dummy name.
nodeService.createNode(productLibraryNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "name"), HCCustomModel.QNAME_PRODUCT_TYPE_FOLDER, productMap);
}
else{
throw new AlfrescoRuntimeException("productMap can not be null");
}
} catch (InvalidTypeException | InvalidQNameException e) {
logger.error("Exceptio Occurred while creating new Node"+ e.getMessage());
}
} catch (InvalidNodeRefException | JSONException e) {
logger.error("Error occured while Creating properties from Json Object."
+ e.getMessage());
}
}
//generateProductMap() has the custom logic to convert the generated JSONData into productMap of (Map<QName, Serialisable>)
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.