Welcome to Atalasoft Community Sign in | Join | Help

RemoteInvokes invoke remotely.

(Scribe’s note: throughout this post I’m going to refer to the WebImageViewer, but everything will apply to the WebAnnotationViewer as well.  The converse, though, isn’t true; if I refer to Annotations, that only applies to the WebAnnotationViewer and not the WebImageViewer.)

The doorknob said, “Read the directions and directly you will be directed in the right direction.” 

One of the most used features, and least understood, in DotImage is the WebImageViewer’s RemoteInvoke.   The RemoteInvoke function in JavaScript calls a server-side function without doing a postback to the server.

The benefits are that you can perform image processing (rotate, despeckle, burn annotations) without reloading your entire page – only the WebImageViewer will update itself.

The drawbacks are that only the WebImageViewer will update itself.

Our AJAX Specialist Dave  gave the following analogy to a customer recently: think of the RemoteInvoke as a bubble.  This bubble surrounds the WebImageViewer and doesn’t know anything else exists.  That means it doesn’t know the WebThumbnailViewer exists.  Also, the WebImageViewer only holds one image at a time – there is no ImageCollection associated with the WebImageViewer.  That means it also doesn’t know that any other images exist.

However, that doesn’t mean you can’t work with multiple images.  If you use the OpenUrl method to open your image in the WebImageViewer, then the ImageUrl property is the URL linking to your file.  From this file, you can generate an ImageCollection, which will give you access to all the pages of your file.  You can then perform image processing on the image in the viewer, and replace that image in your ImageCollection.  WebImageViewer.CurrentPage will tell you which page you are looking at (careful, though – CurrentPage is one-index based, while the ImageCollection is zero-indexed).  Save your changes back to the file with the URL and the appropriate encoder.

Remember, your WebThumbnailViewer doesn’t know anything has happened.  You’re still inside your RemoteInvoke bubble, changing the file on the server.  If you return your URL from your server-side function, you can get this string by calling WebImageViewer.getReturnValue() in your JavaScript.  Then, use that URL in the WebThumbnailViewer.OpenUrl call (still in JavaScript), and your WebThumbnailViewer will reflect the changes you made server-side.

When using RemoteInvokes, there are two calls on the JavaScript side.  One is RemoteInvoke (present-tense), in which you pass the name of the server-side function you want to call and an array holding the variable parameters for the function.  Two is RemoteInvoked (past-tense), an event in which you assign the function you want called when the RemoteInvoke returns from the server-side processing.  It is important to assign the RemoteInvoked event BEFORE you call the RemoteInvoke process (the DotImage ASP.Net Web Demo actually has this wrong in its JavaScript examples).

This is only a brief overview of the RemoteInvoke function.  To go deeper, you’ll need to take the red pill .

Published Friday, November 21, 2008 7:51 PM by Elaine

Comments

No Comments
Anonymous comments are disabled