This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Is it possible to call a server side method from the java script in a form? (e.g. Field Event script)

dhenning - Wednesday, December 17, 2008 4:28 PM:

I would like to be able to invoke a server side method that would go do a task based on parameters passed to it and return a string (or object) from a method (client side javascript) that I would bind to a form field in the Field Event - onClick .   For example, on click ,  gather the values in three fields on the form (I have done this much so far) and pass those values to the server side method where it goes off and talks to another application and returns the result to the javascript where I can then display that result. 

 I have searched through the examples, scoured the API course manual I have  and can't find an example of how to pull this off.  Is it possible?  Seems like with all the communication back tothe server that the form does, it ought to be doable....I'm just having a hard time getting my head around how to do...what method is available at that client side environment to do it.

 A simple example would be sufficient to get me passed this mental block.

Thanks.



tstickel - Tuesday, December 23, 2008 7:58 PM:

 Hi;

In the Innovator Programmers Guide there is a short section that gives a partial example on how to have a client-side method call a server-side method.  Below is an excerpt from the Programmers Guide.  What's missing in the example is the code for the server-side method itself.  I don't have an example with me (I am travelling), but I do have one at home that I will post in the next day or two.

 

7.12 Apply a Generic Method

You want to write Generic Methods that can be used as subroutines for other

Methods.

Technique

Use the

Innovator.applyMethod() method to apply Generic Methods. The following

examples assume a server-side method named "Reverse String" exists, and that it

returns a result item containing the reversed contents of the <string> tag.

JavaScript

var inn = this.newInnovator();

var results = inn.applyMethod("Reverse String", "<string>abc</string>");

return results.getResult(); // returns "cba"



tstickel - Thursday, December 25, 2008 10:55 AM:

As promised, below is a VB server method for "Reverse String":

Dim myInnov As Innovator = Me.newInnovator()

Dim

inString As String = Me.getProperty("string")

Dim

outString As String = StrReverse(inString)

Return

(myInnov.newResult(outString))