Expand my Community achievements bar.

SOLVED

Why AEM appear an error "unspecified error" ?

Avatar

Former Community Member

hi there,

i added an button in the sidekick with the following script code:

CQ.Ext.ns("MyClientLib"); MyClientLib.ContentFinder = { addToCart: function(sk){ var pagePanel = sk.panels["PAGE"]; var button = pagePanel.findBy(function(comp){ return comp["name"] == "ADD2_CART"; }, pagePanel); if(button && button.length > 0){ return; } button = { xtype: "button", scope: sk, name: "ADD2_CART", text: "Add to cart", "context": [ CQ.wcm.Sidekick.PAGE ], handler: function(){ //store to cart var pagePath = CQ.WCM.getPagePath(); var params = {"nodePath": pagePath}; CQ.HTTP.post("/bin/mySearchServlet", function(options, success, response) { if (!success) { CQ.Ext.Msg.alert( CQ.I18n.getMessage("Error"), CQ.I18n.getMessage("Could not add current page to cart.")); } else { CQ.Ext.Msg.alert("Success","Current Page has been put into cart"); } },params); } }; pagePanel.insert(10,button); sk.actns.push(button); } }; (function(){ var result; CQ.Ext.Ajax.request({ url: CQ.HTTP.externalize("/bin/customer"), method: "GET", success: function(response) { var info = CQ.Ext.util.JSON.decode(response.responseText); var ack = info[0].result; result = ack; }, failure: function(response) { } }); var c = MyClientLib.ContentFinder; if( ( window.location.pathname == "/cf" ) || ( window.location.pathname.indexOf("/content") == 0)){ var SK_INTERVAL = setInterval(function(){ var sk = CQ.WCM.getSidekick(); if(sk){ clearInterval(SK_INTERVAL); //Add to cart c.addToCart(sk); } }, 250); } })();

But when i press "add to cart", it appear a small popup dialogue, please see below:

[img]unspecifiederror.png[/img]

 

Anybody knows how to deal with it?

Thanks a lot.

 

Best regards,

Brian

1 Accepted Solution

Avatar

Correct answer by
Level 9
3 Replies

Avatar

Correct answer by
Level 9

Avatar

Level 10

Why do you want to call servlets from the sidekick? Shouldn;t your servlets be called from pages?

Avatar

Former Community Member

Maybe you are right, but i am new to AEM and wondering how to make servlet be called from pages?

Thanks a lot.