zembly Programming Model



Srividhya Narayanan, Sr. Engineering Manager


                                               1
Agenda
• Building Blocks
• Language Reference
• Web APIs
• Building a FB application




                              2
Building Blocks
• Widgets
     > Are ...
           ● User interface (rendered in browser)
• Data Services
     > Are …
  ...
Widgets
• Are...
      > 3 things – HTML, CSS, JavaScript
      > Flavors
            ● FB: FBML, FBJS




               ...
Data Services
• Are...
      > JavaScript 1.6 including E4X
      > Called from widgets or from other services




       ...
API
• Are...
      > RESTful services
      > WADL(Web Application Description Language)
          described
      > Calle...
Language Reference




                     7
Data Services
• Input
   // Get value of a parameter
  var a = Parameters.param1;


• Output
   // Returning a String
  re...
Data Services
Calling a service from other service
 • Calling zembly created Data service – Using Things
   object
  var r...
Data Services
Error Occurs when
 • Problems with the request or caller, for example, a
   required parameter wasn't specif...
Data Services
Error Object
 • error.code - Error code returned by the service, or by the
   platform. Error code is always...
Data Services
• Error Handling
     > Using try-catch block
     > Throwing errors from services
• Logging in Services
   ...
Widgets
• Parameters
     > As properties of Parameter object:
       Parameters.x
     > As Markup expressions:
       <h...
Widgets
• Calling a service from a widget
      > service invocations from widgets are asynchronous
      > Things.callSer...
Widgets
• Logging
     > Alert()
     > Log object
          ● default logging is turned off when executing
              ...
Web APIs




           16
17
API
• Zembly exposed Web APIs
• Bring Your Own API into zembly.
  http://wiki.zembly.com/wiki/Bring_Your_Own_API
• NetBean...
Facebook Demo




                19
Thank You!



srividhya.narayanan@sun.com


                              20
Upcoming SlideShare
Loading in …5
×

Zembly Programming Language

9,488 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
9,488
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Zembly Programming Language

  1. 1. zembly Programming Model Srividhya Narayanan, Sr. Engineering Manager 1
  2. 2. Agenda • Building Blocks • Language Reference • Web APIs • Building a FB application 2
  3. 3. Building Blocks • Widgets > Are ... ● User interface (rendered in browser) • Data Services > Are … ● Back-end logic • API > Are … ● Externally available value-added services 3
  4. 4. Widgets • Are... > 3 things – HTML, CSS, JavaScript > Flavors ● FB: FBML, FBJS 4
  5. 5. Data Services • Are... > JavaScript 1.6 including E4X > Called from widgets or from other services 5
  6. 6. API • Are... > RESTful services > WADL(Web Application Description Language) described > Called from other widgets and services > Keyset managed in zembly 6
  7. 7. Language Reference 7
  8. 8. Data Services • Input // Get value of a parameter var a = Parameters.param1; • Output // Returning a String return quot;Hello world!quot;; // Returning an Object return { foo: quot;barquot; }; 8
  9. 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 9
  10. 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 10
  11. 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 quot;human readablequot; 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. 11
  12. 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 12
  13. 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> 13
  14. 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/cb1812d5a786455b82 331045884ca7f9 • 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. 14
  15. 15. Widgets • Logging > Alert() > Log object ● default logging is turned off when executing published widgets; • Keychain > Not available 15
  16. 16. Web APIs 16
  17. 17. 17
  18. 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 18
  19. 19. Facebook Demo 19
  20. 20. Thank You! srividhya.narayanan@sun.com 20

×