La Ragic Guía
Transformando la manera en que tu negocio funciona con sistema TI y servicios cloud
¡Síguenos en redes sociales!
Trending
Applications
Case Studies
What is Ragic
Talking Ragic
Facebook X YouTube
Producto
Guía
Acerca
Trending
Applications
Case Studies
What is Ragic
Talking Ragic

Javascript data types vs. Java data types

Por Jeff Kuo

One of the most common problem Ragic developers encounter is the difference between Javascript data types and Java data types in workflow programs. Our workflow engine runs on Rhino java scripting engine, and here's some advice from Mozilla that may help developers:

https://developer.mozilla.org/en-US/docs/Scripting_Java

The difference between Java Strings and Javascript Strings is actually the most common problem:

Java Strings and JavaScript Strings

It's important to keep in mind that Java strings and JavaScript strings are not the same. Java strings are instances of the type java.lang.String and have all the methods defined by that class. JavaScript strings have methods defined by String.prototype. The most common stumbling block is length, which is a method of Java strings and a dynamic property of JavaScript strings:

js> javaString = new java.lang.String("Java")

Java

js> jsString = "JavaScript"

JavaScript

js> javaString.length()

4

js> jsString.length

10

Rhino provides some help in reducing the differences between the two types. First, you can pass a JavaScript string to a Java method that requires a Java string and Rhino will perform the conversion. We actually saw this feature in action on the call to the java.lang.String constructor in the preceding example.

Rhino also makes the JavaScript methods available to Java strings if the java.lang.String class doesn't already define them. For example:

js> javaString.match(/a.*/)

ava

¡Impulsado por Ragic! : La Gestión de Datos Que Sí Funciona.
Mantener tus datos en Excel no sólo afecta tu productividad, también es propenso a errores sin tener manera de auditar. Mientras tu equipo crece, el manejo de datos con hojas de cálculo se vuelve extremadamente tedioso.
¡Crea tu primera base de datos ahora!

Iniciar Ragic Gratis

Registrarse con Google