zembly programming language
TRANSCRIPT
![Page 1: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/1.jpg)
zembly Programming Model
1
Srividhya Narayanan, Sr. Engineering Manager
![Page 2: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/2.jpg)
2
Agenda
• Building Blocks• Language Reference• Web APIs• Building a FB application
![Page 3: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/3.jpg)
3
Building Blocks
• Widgets> Are ...
●User interface (rendered in browser)
• Data Services> Are …
●Back-end logic
• API> Are …
●Externally available value-added services
![Page 4: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/4.jpg)
4
Widgets
• Are...> 3 things – HTML, CSS, JavaScript> Flavors
●FB: FBML, FBJS
![Page 5: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/5.jpg)
5
Data Services
• Are...> JavaScript 1.6 including E4X> Called from widgets or from other services
![Page 6: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/6.jpg)
6
API
• Are...> RESTful services > WADL(Web Application Description Language)
described> Called from other widgets and services> Keyset managed in zembly
![Page 7: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/7.jpg)
7
Language Reference
![Page 8: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/8.jpg)
8
Data Services
• Input // Get value of a parameter var a = Parameters.param1;
• Output // Returning a String return "Hello world!";
// Returning an Object
return { foo: "bar" };
![Page 9: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/9.jpg)
9
Data Services
Calling a service from other service
• Calling zembly created Data service – Using Things object
var result = Things.codename.serviceName(parameters);
• Calling external Web API - Using Web object var result = Web.domain.api.serviceName(parameters);
• Passing identity credentials> From keychain using Owner.keychain> Generating on the fly
![Page 10: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/10.jpg)
10
Data Services
Error Occurs when
• Problems with the request or caller, for example, a required parameter wasn't specified
• Syntax errors in the service code
• JavaScript runtime errors in the service code, such as reference to undefined variable
• Uncaught errors from a nested service invocation
• Errors thrown from the service code
• Platform errors
![Page 11: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/11.jpg)
11
Data Services
Error Object
• error.code - Error code returned by the service, or by the platform. Error code is always included.
• error.message - Message may provide a "human readable" information about the error.
• error.details - Details property may carry a structured information about the error.
• error.httpStatusCode - HTTP status code that was used in the service response.
![Page 12: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/12.jpg)
12
Data Services
• Error Handling> Using try-catch block> Throwing errors from services
• Logging in Services> Log.write(message)> Log.log(message)> Log.debug> Log.info
● All these 4 methods currently add a message to the execution log with info level.
> Log.warn - Adds a message to the execution log with warning level
> Log.error - Adds a message to the execution log with error level
![Page 13: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/13.jpg)
13
Widgets
• Parameters> As properties of Parameter object:
Parameters.x> As Markup expressions:
<h1>Hello ${Parameter.name}</h1>> Markup with a scriptlet
<h1>Hi <?=${Parameter.name}</h1>
![Page 14: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/14.jpg)
14
Widgets
• Calling a service from a widget> service invocations from widgets are asynchronous> Things.callService(serviceName, parameters,
options)> Web.callService(serviceName, parameters,
options) - http://zembly.com/things/cb1812d5a786455b82331045884ca7f9
• Service invocation callbacks> options.onSuccess : function(data)> options.onSuccess : function(data, transport,
options)> Service result comes back in data parameter> options.onFailure : function(error)> Error parameter contains the code, message, HTTP status
code and details of the error.
![Page 15: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/15.jpg)
15
Widgets
• Logging> Alert()> Log object
●default logging is turned off when executing published widgets;
• Keychain> Not available
![Page 16: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/16.jpg)
16
Web APIs
![Page 17: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/17.jpg)
17
![Page 18: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/18.jpg)
18
API
• Zembly exposed Web APIs
• Bring Your Own API into zembly. http://wiki.zembly.com/wiki/Bring_Your_Own_API
• NetBeans WADL designer. http://www.netbeans.org/kb/docs/websvc/wadl-zembly.html
![Page 19: Zembly Programming Language](https://reader033.vdocuments.us/reader033/viewer/2022052303/555029c2b4c905de2d8b4a5a/html5/thumbnails/19.jpg)
19
Facebook Demo