Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

How to invoke OSGI bundle in the sidekick.js

Avatar

Former Community Member

Because i need to add an button[Add to cart] into sidekick after write code in file sidekick.js, please see following screenshot. Here my requirement is to collect this current page or node path to store in somewhere if user to press this button [Add to cart]. I am a new to AEM and already complete a OSGI bundle to save it. But best confused me is i don't know how and where to invoke this bundle?

Anyone could help see this question? Thanks a lot. Anyway if anybody have better solution for that, please comment on it. Thanks again.

[img]sidekick2.png[/img]

public int add2Cart(Node node) throws Exception { final int OK = 1; final int EXISTED = -1; String cart = "cart"; session = this.getSession(); Node root = session.getRootNode(); Node content = root.getNode("content"); Node cartRoot = null; int cartRec = this.doesNodeExist(content, cart); if (cartRec == -1) { cartRoot = content.addNode(cart, "sling:OrderedFolder"); } else { cartRoot = content.getNode(cart); } Node userCartNode = null; String userCart = cart + "-" + this.getCurrentUserId(); int userRec = this.doesNodeExist(cartRoot, userCart); if (userRec == -1) { userCartNode = cartRoot.addNode(userCart, "nt:unstructured"); } else { userCartNode = cartRoot.getNode(userCart); } // verify if this property existed. Property prop = userCartNode.getProperty(node.getName()); if (prop == null) { userCartNode.setProperty(node.getName(), node.getName()); } else { return EXISTED; } session.save(); return OK; }
1 Accepted Solution

Avatar

Correct answer by
Level 10

Along with jorg suggestion look for couple of sidekick example to add and invoke calls at http://experience-aem.blogspot.com/2013/08/in-blog-experiencing-adobe-experience.html

View solution in original post

2 Replies

Avatar

Employee Advisor

Hi,

Your button should invoke a call to the server (normally to a servlet). Then this servlet can do the necessary work and e.g. call your code.

Avatar

Correct answer by
Level 10

Along with jorg suggestion look for couple of sidekick example to add and invoke calls at http://experience-aem.blogspot.com/2013/08/in-blog-experiencing-adobe-experience.html