Dashlet custom properties displayed on PopUp
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2014 10:25 AM
When I click on my dashlet link, I get an error and my popUp can't be displaying
Uncaught TypeError: undefined is not a function
Uncaught TypeError: Cannot read property 'attributes' of null (attributes in "simple-dialog.js")
I get the data on my share console, and I do not understand why I'm getting this error.
Can anybody help me, please HELP me, I don't understand this task.
Every help will be gratefull
))
<javascript>
//<![CDATA[
new Alfresco.FormUI("div-form", "div").setOptions(
{
mode: "create",
enctype: "application/json",
fields:
[
{
id : "prop_ca_title"
}
,
{
id : "prop_ca_category"
}
,
{
id : "prop_ca_description"
}
],
fieldConstraints:
[
{
fieldId : "div_prop_ca_title",
handler : Alfresco.forms.validation.mandatory,
params : {},
event : "keyup,propertychange",
message : "………."
}
,
{
fieldId : "div_prop_ca_title",
handler : Alfresco.forms.validation.length,
params : {"maxLength":50,"minLength":0,"crop":true},
event : "keyup",
message : "La valeur inclut un nombre de caractères incorrect."
}
,
{
fieldId : "div_prop_ca_description",
handler : Alfresco.forms.validation.length,
params : {"maxLength":256,"minLength":0,"crop":true},
event : "keyup",
message : "……….."
}
,
{
fieldId : "div_prop_ca_category",
handler : Alfresco.forms.validation.inList,
params : {"sorted":false,"caseSensitive":true,"allowedValues": ["Sport|Sport","News|News","Finance|Finance","Kitchen|Kitchen"]},
event : "blur",
message : "……….."
}
]
}).setMessages(
{"form.cont ………………."}
);
//]]>
</javascript>
list-news.js
<javascript>
if (typeof custom == "undefined" || !custom){
var custom = {};
custom.dashlet = {};
}
(function() {
var Dom = YAHOO.util.Dom,
Event = YAHOO.util.Event;
var $html = Alfresco.util.encodeHTML,
$combine = Alfresco.util.combinePaths;
custom.dashlet.list_news = function list_news_constructor(htmlId) {
custom.dashlet.list_news.superclass.constructor.call(this, "custom.dashlet.list_news", htmlId);
this.configDialog = null;
//Register the component
Alfresco.util.ComponentManager.register(this);
//Load YUI components
Alfresco.util.YUILoaderHelper.require(["button", "container", "datasource", "datatable", "paginator", "json", "history",
"tabview"], this.onComponentsLoaded, this);
return this;
};
YAHOO.extend(custom.dashlet.list_news, Alfresco.component.Base,
{
options:
{
componentId : "",
title : "",
description : "",
category : ""
},
configDialog: null,
setOptions: function list_news_setOptions(obj)
{
this.options = YAHOO.lang.merge(this.options, obj);
return this;
},
onComponentsLoaded: function list_news_onComponentsLoaded()
{
Event.onContentReady(this.id, this.onReady, this, true);
},
//widgets: {},
onReady: function list_news_onReady() {
var me = this;
// Add click handler to config news link that will be visible if user is site manager.
var configFeedLink = Dom.get(this.id + "-config-link");
Event.addListener(configFeedLink, "click", this.onConfigListNewsClick, this, true);
},
onConfigListNewsClick : function list_news_onConfigListNewsClick(e) {
var actionUrl = Alfresco.constants.URL_SERVICECONTEXT + "modules/list-news/config/" +
encodeURIComponent(this.options.componentId);
Event.stopEvent(e);
/*function computeRedirectUrl(){
var scope = "window.parent.Alfresco.util.ComponentManager.get('" + this.id + "')";
var successCallback = "window.parent.Alfresco.util.ComponentManager.get('" + this.id + "-configDialog')" +
".options.onSuccess.fn";
var failureCallback = "window.parent.Alfresco.util.ComponentManager.get('" + this.id + "-configDialog')" +
".options.onFailure.fn";
var params = {
successCallback: successCallback,
successScope: scope,
failureCallback: failureCallback,
failureScope: scope
}
var url = Alfresco.constants.URL_SERVICECONTEXT + "modules/list-news/config?";
url += "params=" + JSON.stringify(params);
return url;
}*/
var doSetupFormsValidation = function list_news_doSetupFormsValidation(form){
//Name: mandatory
//form.addValidation(this.id + "_prop_ca_title", Alfresco.forms.validation.mandatory, null, "keyup");
//form.addValidation(this.configDialog.id + "-title", Alfresco.forms.validation.nodeName, null, "keyup");
//form.setShowSubmitStateDynamically(true, false);
/*Dom.get(this.configDialog.id + "-title").value = this.options.titleStr;
Dom.get(this.configDialog.id + "-description").value = this.options.descriptionStr;
Dom.get(this.configDialog.id + "-category").value = this.options.categoryStr;*/
/*var doBeforeDialogShow = function list_news_doBeforeDialogShow(p_form, p_dialog) {
Alfresco.util.populateHTML();
Dom.get(p_dialog.id + "-configDialog").value = this.options.componentId;
}*/
var elem = Dom.get(this.configDialog.id + "-title");
if (elem) {
elem.value = this.options.title;
}
var elem = Dom.get(this.configDialog.id + "-description");
if (elem) {
elem.value = this.options.description;
}
var elem = Dom.get(this.configDialog.id + "-category");
if (elem) {
elem.value = this.options.category;
}
};
var templateUrl = YAHOO.lang.substitute(Alfresco.constants.URL_SERVICECONTEXT +
"components/form?itemKind={itemKind}&itemId={itemId}&htmlid={htmlid}&destination={destination}" +
"&mode={mode}&submitType={submitType}&formId={formId}&showCancelButton=true",
{
itemKind: "type",
itemId: "ca:entryFormNews",
htmlid: "div",
destination: "${form.destination?html}",
mode: "create",
submitType: "json",//multipart
formId: "custom-metadata"
//redirect: computeRedirectUrl()
});
if(!this.configDialog) {
this.configDialog = new Alfresco.module.SimpleDialog(this.id + "-configDialog").setOptions(
{
width: "100em",
templateUrl: templateUrl,
actionUrl: null,
destroyOnHide: true,
doSetupFormsValidation:
{
fn: doSetupFormsValidation,
scope: this
},
onSuccess:
{
fn: function list_news_onConfig_success(response) {
var div = Dom.get(this.id + "-form");
div.innerHTML = response.serverResponse.responseText;
var form = Dom.getFirstChildBy(div, function(node) {
return (node.tagName.toUpperCase() == "FORM");
});
if (form) {
if (form.attributes["prop_ca_title"]) {
var testLogin = form.attributes["title"].value;
}
if (form.attributes["description"]) {
var testPass = form.attributes["description"].value;
}
if (form.attributes["category"]) {
var testPass = form.attributes["category"].value;
}
}
/*var obj = response.json;
if(obj) {
this.options = YAHOO.lang.merge(this.options, obj);
}
var result = eval('(' + obj + ')');*/
Alfresco.util.PopupManager.displayMessage(
{
text: this.msg("message.success")
});
Alfresco.util.Ajax.request({
url: Alfresco.constants.URL_SERVICECONTEXT + "modules/list-news/config/",
dataObj: templateUrl,
method: Alfresco.util.Ajax.GET,
successCallback: {
fn :this.onComponentsLoaded,
obj: this,
scope:this
},
failureCallback: {
fn :this._formLoadFailure,
obj: this,
scope:this
},
scope: this,
execScripts: true
});
},
scope: this
},
onFailure:
{
fn: function list_news_onConfig_failure(response) {
Alfresco.util.PopupManager.displayMessage(
{
text: this.msg("message.failure")
});
},
scope: this
}
});
} else {
this.configDialog.setOptions(
{
actionUrl: actionUrl
});
}
this.configDialog.setOptions(
{
actionUrl: actionUrl
}).show();
return this.configDialog;
}
});
})();
</javascript>
Uncaught TypeError: undefined is not a function
Uncaught TypeError: Cannot read property 'attributes' of null (attributes in "simple-dialog.js")
I get the data on my share console, and I do not understand why I'm getting this error.
Can anybody help me, please HELP me, I don't understand this task.
Every help will be gratefull

<javascript>
//<![CDATA[
new Alfresco.FormUI("div-form", "div").setOptions(
{
mode: "create",
enctype: "application/json",
fields:
[
{
id : "prop_ca_title"
}
,
{
id : "prop_ca_category"
}
,
{
id : "prop_ca_description"
}
],
fieldConstraints:
[
{
fieldId : "div_prop_ca_title",
handler : Alfresco.forms.validation.mandatory,
params : {},
event : "keyup,propertychange",
message : "………."
}
,
{
fieldId : "div_prop_ca_title",
handler : Alfresco.forms.validation.length,
params : {"maxLength":50,"minLength":0,"crop":true},
event : "keyup",
message : "La valeur inclut un nombre de caractères incorrect."
}
,
{
fieldId : "div_prop_ca_description",
handler : Alfresco.forms.validation.length,
params : {"maxLength":256,"minLength":0,"crop":true},
event : "keyup",
message : "……….."
}
,
{
fieldId : "div_prop_ca_category",
handler : Alfresco.forms.validation.inList,
params : {"sorted":false,"caseSensitive":true,"allowedValues": ["Sport|Sport","News|News","Finance|Finance","Kitchen|Kitchen"]},
event : "blur",
message : "……….."
}
]
}).setMessages(
{"form.cont ………………."}
);
//]]>
</javascript>
list-news.js
<javascript>
if (typeof custom == "undefined" || !custom){
var custom = {};
custom.dashlet = {};
}
(function() {
var Dom = YAHOO.util.Dom,
Event = YAHOO.util.Event;
var $html = Alfresco.util.encodeHTML,
$combine = Alfresco.util.combinePaths;
custom.dashlet.list_news = function list_news_constructor(htmlId) {
custom.dashlet.list_news.superclass.constructor.call(this, "custom.dashlet.list_news", htmlId);
this.configDialog = null;
//Register the component
Alfresco.util.ComponentManager.register(this);
//Load YUI components
Alfresco.util.YUILoaderHelper.require(["button", "container", "datasource", "datatable", "paginator", "json", "history",
"tabview"], this.onComponentsLoaded, this);
return this;
};
YAHOO.extend(custom.dashlet.list_news, Alfresco.component.Base,
{
options:
{
componentId : "",
title : "",
description : "",
category : ""
},
configDialog: null,
setOptions: function list_news_setOptions(obj)
{
this.options = YAHOO.lang.merge(this.options, obj);
return this;
},
onComponentsLoaded: function list_news_onComponentsLoaded()
{
Event.onContentReady(this.id, this.onReady, this, true);
},
//widgets: {},
onReady: function list_news_onReady() {
var me = this;
// Add click handler to config news link that will be visible if user is site manager.
var configFeedLink = Dom.get(this.id + "-config-link");
Event.addListener(configFeedLink, "click", this.onConfigListNewsClick, this, true);
},
onConfigListNewsClick : function list_news_onConfigListNewsClick(e) {
var actionUrl = Alfresco.constants.URL_SERVICECONTEXT + "modules/list-news/config/" +
encodeURIComponent(this.options.componentId);
Event.stopEvent(e);
/*function computeRedirectUrl(){
var scope = "window.parent.Alfresco.util.ComponentManager.get('" + this.id + "')";
var successCallback = "window.parent.Alfresco.util.ComponentManager.get('" + this.id + "-configDialog')" +
".options.onSuccess.fn";
var failureCallback = "window.parent.Alfresco.util.ComponentManager.get('" + this.id + "-configDialog')" +
".options.onFailure.fn";
var params = {
successCallback: successCallback,
successScope: scope,
failureCallback: failureCallback,
failureScope: scope
}
var url = Alfresco.constants.URL_SERVICECONTEXT + "modules/list-news/config?";
url += "params=" + JSON.stringify(params);
return url;
}*/
var doSetupFormsValidation = function list_news_doSetupFormsValidation(form){
//Name: mandatory
//form.addValidation(this.id + "_prop_ca_title", Alfresco.forms.validation.mandatory, null, "keyup");
//form.addValidation(this.configDialog.id + "-title", Alfresco.forms.validation.nodeName, null, "keyup");
//form.setShowSubmitStateDynamically(true, false);
/*Dom.get(this.configDialog.id + "-title").value = this.options.titleStr;
Dom.get(this.configDialog.id + "-description").value = this.options.descriptionStr;
Dom.get(this.configDialog.id + "-category").value = this.options.categoryStr;*/
/*var doBeforeDialogShow = function list_news_doBeforeDialogShow(p_form, p_dialog) {
Alfresco.util.populateHTML();
Dom.get(p_dialog.id + "-configDialog").value = this.options.componentId;
}*/
var elem = Dom.get(this.configDialog.id + "-title");
if (elem) {
elem.value = this.options.title;
}
var elem = Dom.get(this.configDialog.id + "-description");
if (elem) {
elem.value = this.options.description;
}
var elem = Dom.get(this.configDialog.id + "-category");
if (elem) {
elem.value = this.options.category;
}
};
var templateUrl = YAHOO.lang.substitute(Alfresco.constants.URL_SERVICECONTEXT +
"components/form?itemKind={itemKind}&itemId={itemId}&htmlid={htmlid}&destination={destination}" +
"&mode={mode}&submitType={submitType}&formId={formId}&showCancelButton=true",
{
itemKind: "type",
itemId: "ca:entryFormNews",
htmlid: "div",
destination: "${form.destination?html}",
mode: "create",
submitType: "json",//multipart
formId: "custom-metadata"
//redirect: computeRedirectUrl()
});
if(!this.configDialog) {
this.configDialog = new Alfresco.module.SimpleDialog(this.id + "-configDialog").setOptions(
{
width: "100em",
templateUrl: templateUrl,
actionUrl: null,
destroyOnHide: true,
doSetupFormsValidation:
{
fn: doSetupFormsValidation,
scope: this
},
onSuccess:
{
fn: function list_news_onConfig_success(response) {
var div = Dom.get(this.id + "-form");
div.innerHTML = response.serverResponse.responseText;
var form = Dom.getFirstChildBy(div, function(node) {
return (node.tagName.toUpperCase() == "FORM");
});
if (form) {
if (form.attributes["prop_ca_title"]) {
var testLogin = form.attributes["title"].value;
}
if (form.attributes["description"]) {
var testPass = form.attributes["description"].value;
}
if (form.attributes["category"]) {
var testPass = form.attributes["category"].value;
}
}
/*var obj = response.json;
if(obj) {
this.options = YAHOO.lang.merge(this.options, obj);
}
var result = eval('(' + obj + ')');*/
Alfresco.util.PopupManager.displayMessage(
{
text: this.msg("message.success")
});
Alfresco.util.Ajax.request({
url: Alfresco.constants.URL_SERVICECONTEXT + "modules/list-news/config/",
dataObj: templateUrl,
method: Alfresco.util.Ajax.GET,
successCallback: {
fn :this.onComponentsLoaded,
obj: this,
scope:this
},
failureCallback: {
fn :this._formLoadFailure,
obj: this,
scope:this
},
scope: this,
execScripts: true
});
},
scope: this
},
onFailure:
{
fn: function list_news_onConfig_failure(response) {
Alfresco.util.PopupManager.displayMessage(
{
text: this.msg("message.failure")
});
},
scope: this
}
});
} else {
this.configDialog.setOptions(
{
actionUrl: actionUrl
});
}
this.configDialog.setOptions(
{
actionUrl: actionUrl
}).show();
return this.configDialog;
}
});
})();
</javascript>
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2014 02:38 PM
Could you please first provide what customization you have implemented for the dashlet?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2014 02:43 AM
Thanks for your answer !
I have create a dashlet with a configure link, when it's clicked I can add a product by editing his title, description & category then I submit it to the document library of my specific site.
Into my dashlet I can save the information aboout my product.
Here is my ftl file :
<javascript>
<#assign el=args.htmlid?js_string>
<script type="text/javascript">//<![CDATA[
(function() {
var list_news = new custom.dashlet.list_news("${args.htmlid}").setOptions(
{
"componentId": "${instance.object.id}",
"title": "${title}",
"description": "${description}",
"category": "${category}",
}).setMessages(${messages});
new Alfresco.widget.DashletResizer("${args.htmlid}", "${instance.object.id}");
new Alfresco.widget.DashletTitleBarActions("${args.htmlid?html}").setOptions(
{
actions:
[
{
cssClass: "help",
bubbleOnClick:
{
message: "${msg("dashlet.help")?js_string}"
},
tooltip: "${msg("dashlet.help.tooltip")?js_string}"
}
]
});
})();
//]]></script>
<div class="dashlet list_news">
<div id="list_news_title" class="title">${msg("header.list-news")}</div>
<div class="toolbar flat-button">
<a id="${el}-config-link" class="configure theme-color-1" href="#">${msg("config")}</a>
</div>
<div class="body scrollablePanel" <#if args.height??>style="height: ${args.height}px;"</#if>>
<div class="detail-list-item first-item last-item">
<h2><span id="${el}-title">${title}</span></h2>
<p><span id="${el}-description">${description}</span></p>
<p><span id="${el}-category">${category}</span></p>
</div>
</div>
</div>
</javascript>
Please Help me
Thanks & Regards,
I have create a dashlet with a configure link, when it's clicked I can add a product by editing his title, description & category then I submit it to the document library of my specific site.
Into my dashlet I can save the information aboout my product.
Here is my ftl file :
<javascript>
<#assign el=args.htmlid?js_string>
<script type="text/javascript">//<![CDATA[
(function() {
var list_news = new custom.dashlet.list_news("${args.htmlid}").setOptions(
{
"componentId": "${instance.object.id}",
"title": "${title}",
"description": "${description}",
"category": "${category}",
}).setMessages(${messages});
new Alfresco.widget.DashletResizer("${args.htmlid}", "${instance.object.id}");
new Alfresco.widget.DashletTitleBarActions("${args.htmlid?html}").setOptions(
{
actions:
[
{
cssClass: "help",
bubbleOnClick:
{
message: "${msg("dashlet.help")?js_string}"
},
tooltip: "${msg("dashlet.help.tooltip")?js_string}"
}
]
});
})();
//]]></script>
<div class="dashlet list_news">
<div id="list_news_title" class="title">${msg("header.list-news")}</div>
<div class="toolbar flat-button">
<a id="${el}-config-link" class="configure theme-color-1" href="#">${msg("config")}</a>
</div>
<div class="body scrollablePanel" <#if args.height??>style="height: ${args.height}px;"</#if>>
<div class="detail-list-item first-item last-item">
<h2><span id="${el}-title">${title}</span></h2>
<p><span id="${el}-description">${description}</span></p>
<p><span id="${el}-category">${category}</span></p>
</div>
</div>
</div>
</javascript>
Please Help me

Thanks & Regards,
