JBoss.orgCommunity Documentation

Chapter 12. Gadget development

12.1. Gadgets
12.1.1. Overview
12.1.2. Existing Gadgets
12.1.3. Create a new Gadget
12.1.4. Remote Gadget
12.1.5. Gadget Importing
12.1.6. Gadget Web Editing
12.1.7. Gadget IDE Editing
12.1.8. Dashboard Viewing
12.2. Setup a Gadget Server
12.2.1. Setup virtual servers for the gadget rendering

An gadget is a mini web application running on a platform and you can put it in a web page. This is a small application that helps users to do some private actions.

GateIn Portal supports some gadgets such as: Todo gadget, Calendar gadget, Calculator gadget, Weather Forecasts, RSS Reader gadget.

This is the reference to a remote gadget (stock one).

After referencing the gadget successfully, then import it into the local repository.

Edit it from the Web the imported Gadget to modify it:

Edit it from your IDE thanks to the WebDAV protocol:

View it from the Dashboard when you drag and drop the Gadget from listing to the dashboard.

GateIn recommend you to setup 2 different virtual hosts because it's the basis of the security model of gadgets. Having the gadget running on a different domain than the container (the website that 'contains' the app), the gadget can't read / modify / do anything nasty to GateIn Portal (like adding spam messages, stealing your cookies, whatever).

For example you can server the portal from http://www.sample.com and the gadgets from http://www.samplemodules.com

To do this, we need to configure a parameter with the name is gadgets.hostName , the value is the path/to/gadgetServer in GadgetRegisteryService service like following : {code:xml} <component> <key>org.exoplatform.application.gadget.GadgetRegistryService</key> <type>org.exoplatform.application.gadget.jcr.GadgetRegistryServiceImpl</type> <init-params> <value-param> <name>gadgets.hostName</name> <description>Gadget server url</description> <value>http://localhost:8080/GateInGadgetServer/gadgets/</value> </value-param> </init-params> </component> {code}

It's possible to have multiple rendering servers. That would help to balance the load across multiple servers.

If you still want to deploy it on the same server, make sure that it starts before anything that use the gadgets (for example the webapp GateInGadgets that use org.exoplatform.application.gadget.GadgetRegister)

1 Config 1.1 Security key A file key.txt has to be generated for every installation of GateIn to be secure. This file contains a secret key used to crypt the security token used for authenticating the user. in Tomcat this file is in nix command line will create an excellent key:

dd if=/dev/random bs=32 count=1  | openssl base64 > /tmp/key.txt

1.1 Gadget proxy and concat configuration These servers have to be on the same domain as the gadget server. you can configure it in {code}"link", "script", "embed", "img", "style"{, "expires": "86400", "proxy-url": "http://localhost:8080/GateInGadgetServer/gadgets/proxy?url=", "concat-url": "http://localhost:8080/GateInGadgetServer/gadgets/concat?" }{code}

1.1 Proxy if your server is behind a proxy and you want to allow external gadgets, you should configure the proxy of your JVM adding this code at the begining. {code}-Dhttp.proxyHost=proxyhostURL -Dhttp.proxyPort=proxyPortNumber -Dhttp.proxyUser=someUserName -Dhttp.proxyPassword=somePassword {code}