How to invoke OSGI bundle in the sidekick.js | Community
Skip to main content
October 16, 2015
Solved

How to invoke OSGI bundle in the sidekick.js

  • October 16, 2015
  • 2 replies
  • 809 views

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; }
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Sham_HC

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

2 replies

joerghoh
Adobe Employee
Adobe Employee
October 16, 2015

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.

Sham_HC
Sham_HCAccepted solution
Level 10
October 16, 2015

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