Rhino – JavaScript for Java. Speaker: Brent Wilkins Hertz – Applications Consultant – Cobol developer – 20+ years – PowerBuilder developer – 6 years –

Slides:



Advertisements
Similar presentations
Chapter 7 JavaScript: Introduction to Scripting. Outline Simple Programs Objects and Variables Obtaining User Input with prompt Dialogs – –Dynamic Welcome.
Advertisements

JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
MWD1001 Website Production Using JavaScript with Forms.
Introducing JavaScript
Sue Wills July Objects The JavaScript language is completely centered around objects, and because of this, it is known as an Object Oriented Programming.
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Thursday, September 19, 2013 Session 3: JavaScript.
TECH 2018 (Week 16) Topic: JavaScript Parminder Kang Home: Phones Off Please.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Introduction to JavaScript
Lesson 4: Formatting Input Data for Arithmetic
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Javascript Client-side scripting. Up to now  We've seen a little about how to control  content with HTML  presentation with CSS  Javascript is a language.
Tutorial 10 Programming with JavaScript
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Multiple Tiers in Action
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
CS 299 – Web Programming and Design Overview of JavaScript and DOM Instructor: Dr. Fang (Daisy) Tang.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Introduction to scripting
JavaScript Demo Presented by … Jaisingh Sumit jain Sudhindra Taran Deep arora.
4.1 JavaScript Introduction
 2004 Prentice Hall, Inc. All rights reserved. Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
How Java becomes agile riding Rhino Xavier Casellato VP of engineering, Liligo.com.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Java Script User Defined Functions. Java Script  You can define your own JavaScript functions. Such functions are called user- defined, as opposed to.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
JavaScript Syntax, how to use it in a HTML document
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
1 JavaScript in Context. Server-Side Programming.
Applets, Images, and Audio Chapter 14 CSCI CSCI 1302 – Applets, Images, and Audio2 Outline Introduction The Applet Class –The init Method –The start.
Java Script About Java Script Document Object Model Incorporating JavaScript Adding JavaScript to HTML Embedding a Javascript External Scripts Javascript.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Expressions and Data Types Professor Robin Burke.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
JavaScript: A short introduction Joseph Lee Created by Joseph Lee.
CGS 3066: Web Programming and Design Spring 2017
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
Tutorial 10 Programming with JavaScript
Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript.
Chapter 7 - JavaScript: Introduction to Scripting
JavaScript an introduction.
JavaScript: Introduction to Scripting
Tutorial 10 Programming with JavaScript
JavaScript CS 4640 Programming Languages for Web Applications
Tutorial 10: Programming with javascript
[Robert W. Sebesta, “Programming the World Wide Web
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
JavaScript CS 4640 Programming Languages for Web Applications
Chapter 7 - JavaScript: Introduction to Scripting
Presentation transcript:

Rhino – JavaScript for Java

Speaker: Brent Wilkins Hertz – Applications Consultant – Cobol developer – 20+ years – PowerBuilder developer – 6 years – Java developer – 10+ years – Rhino – JavaScript for Java

What is it? Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically embedded into Java applications to provide scripting to end users. Rhino – JavaScript for Java

Most people who have used JavaScript before have done so by adding scripts to their HTML web pages. However, Rhino is an implementation of the core language only and doesn't contain objects or methods for manipulating HTML documents. Rhino contains: All the features of JavaScript 1.7 Allows direct scripting of Java A JavaScript shell for executing JavaScript scripts A JavaScript compiler to transform JavaScript source files into Java class files A JavaScript debugger for scripts executed with Rhino Rhino – JavaScript for Java

Outline: JavaScript context Optimization levels Initializing and scripting the basic Java objects Scripting custom objects Evaluating JavaScript expressions Rhino – JavaScript for Java

JavaScript Context The Rhino JavaScript Context object is used to store thread-specific information about the execution environment. There should be one and only one Context associated with each thread that will be executing JavaScript. Import org.mozilla.javascript.Context; To associate the current thread with a Context, simply call the enter method of Context: Context jsContext = Context.enter(); Context.exit(); Once you are done with execution, simply exit the Context: Rhino – JavaScript for Java

Optimization Levels Interpretive mode is used. No objects are compiled. 0No optimization is performed. Objects are compiled to bytecode. 1 – 9All optimizations are performed. Rhino – JavaScript for Java

Initializing and scripting the basic Java objects The basic Java objects (String, Boolean, Integer, etc.) must be initialized within the JavaScript Context. This allows for access to custom Java objects from with the Context. org.mozilla.javascript.Scriptable Scriptable script = jsContext.initStandardObjects(); Rhino – JavaScript for Java

Demo time Rhino – JavaScript for Java

Scripting custom objects Convert the object from Java to a JavaScript scriptable object Scriptable jsArgs = Context.toObject( obj, script ); Add the JavaScript object to the other Scriptable objects in the context script.put( objectName, script, jsArgs ); Rhino – JavaScript for Java

Evaluating JavaScript expressions Object result = jsContext.evaluateString( script, expression, expression, 1, null ); Determine the result type of the return object: String String stringResult = Context.toString( result ); Boolean boolean boolResult = Context.toBoolean( result );

Demo time Rhino – JavaScript for Java

Thermal Printing at Hertz Must be able to access data from the Rental Agreement Must be able to evaluate psuedocode that contains: – AND, OR – () order of operations – =, <>,, = – IN and NIN – Evaluates if a variable is in a group of values Rhino – JavaScript for Java

Thermal Printing at Hertz Must be able to access data from the Rental Agreement Must be able to evaluate psuedocode that contains: – AND, OR&&, || – () order of operations – =, <>,, ===, != – IN and NIN – Evaluates if a variable is in a group of values INJava method isInGroup( “|” + var + “|”, “|value|value|value|” ) NIN!isInGroup() Rhino – JavaScript for Java

Demo time Rhino – JavaScript for Java

Resources