[ 
https://issues.apache.org/jira/browse/WOOKIE-421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13815752#comment-13815752
 ] 

Scott Wilson commented on WOOKIE-421:
-------------------------------------

Ah, now I think I understand - thanks Muneeb.

The usual way to request an instance of a widget for embedding in a page is to 
use a plugin for your site that requests the instance. For more information on 
this see: http://wookie.apache.org/docs/embedding.html

Once a widget instance URL has been obtained for your widget, you can then use 
the Preferences REST API to set any values you want scripts within the widget 
to be able to access.

So, using Ajax you would make use of the JavaScript connector at 
/connector/js/wookie-connector.js, and call something like:
    
    var widgetURI = "http://xyz.com/widgets/testwidget";;
    Wookie.configureConnection("http://localhost:9085/wookie";, "MyAPIKey", 
"MySharedDataKey");
    Wookie.setCurrentUser("bob","the bobster","http://bob.com/bob.png";);
   var instance = Wookie.getOrCreateInstance(widgetURI);
    Wookie.setPreference(WidgetURI, "param", "123");

>From within the widget you can now call:

   var param = widget.preferences.getItem("param").

Normally you should use a server-side plugin (there are Java, PHP, Ruby, Python 
variants) as when you use JavaScript from your page there is no way to prevent 
the user from extracting the API key. So use the JS connector with caution, 
e.g. for prototyping only.

S

> How to use request parameters in wookie widget
> ----------------------------------------------
>
>                 Key: WOOKIE-421
>                 URL: https://issues.apache.org/jira/browse/WOOKIE-421
>             Project: Wookie
>          Issue Type: Task
>          Components: Server, Wookie REST API
>    Affects Versions: 0.14.0
>            Reporter: muneeb shabbir
>
> hi,
> Is there any way to pass request parameters to widget deployed on Wookie? i 
> can see Wookie adds some JavaScript files in widget HTML, is there any way 
> where i can receive the request parameters and embed them in the page and 
> using that parameters i want to customize the widget just like Wookie adds 
> JavaScript files in page.
> Thanks in advance



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to