Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

  • I'm writing custom jsp pages, and I need a some help understanding how to use scriptPoint tags. I've read the graphical view dox that discusses server side scripts, but am still confused. :oops:

    <view:scriptPoint xid="DP_123456" raw="true">
    // my script goes here
    </view:scriptPoint>

    • Is the script executed on the server or is it sent back to the browser for execution?

    • What variables are available within the script? It looks like the script will be called with 'value' and 'time' arguments; is that all that are available?

    • Can I call java code through a dwr from this script?

    What I'm trying to do is take a metapoint string value and use it as a key in a <fmt:message> tag. Alternatively, I would like to take a modbus integer error code value and send it to a java method to produce the localized message.

    Thanks for any help anyone can provide.


  • I think I figured out how to do this. I read up on the metapoint dox and noticed that Mango's implementation of javascript is Rhino. Rhino provides the functions importClass() ana importPackage() which allow you access to java code from within your javascript. So, I can call out to java code to to perform the localization of messages.


  • Hi Steve,

    You've talked about two separate things here. The <view:scriptPoint> tag's script runs in the browser; a meta point's script runs on the server. The way to do translations varies depending on the context.


  • After looking at the code I now understand the difference between script point (simply passed on to the browser for execution) and metapoint javascript (executed in the server). My situation is that I have integer error codes coming from the device which need to be turned into localized error messages. There's also a bit of logic involved because of relationships between error codes, so the best option for me is to collect these error code datapoints in a metapoint and process them in java code (via javascript and importClass) and return a localized string message. I've completed the code, and it works quite nicely!

    A nice addition to Mango for users who don't mind writing java code would be java-enabled metapoints. Configuration would include the java class and method to call, perhaps via an xml bean configuration. In this way, the metapoins could bypass the creation of the javascript execution engine and go right to java.


  • Hi Steve,

    You should check out the Rhino documentation. The Java Scripting implementation of it into the JRE might get in the way of some stuff, but you should be able to access a lot of stuff directly within your javascript code. (I have not tested this to any great extent, but in theory it is possible.)

    Also, Rhino does in fact compile scripts to Java for fast execution when the optimization level is properly set. This works in Mango Automation which uses Rhino directly, but M2M uses the Java Scripting impl via which there doesn't appear to be a public way to set the optimization level. Maybe a future version of M2M will use Rhino directly.