What I think makes the approach I took interesting is that it treats the thumbnail of each image you're uploading as the progress indicator of the upload completion: it immediately appends an image tag to the page, with its URL set to the data URI for the file to be uploaded, but sets the opacity of the image to 0. It then splits the Base64 data for the file into several pieces (the client script is structured as a custom Dojo class, and one of the constructor arguments for that class is how many pieces the data should be split into, so you can tweak that as you see fit... right now it's just set to 10). It posts each piece to a JSON-RPC service that keeps track of each piece it receives, then stitches them all together. Depending on how the service is configured, the combined data is either just stored as Base64, or decoded into an actual InputStream so that it can be stored as a true attachment. As the RPC service receives each piece, it reports back that the data was received; the client script updates the opacity of the thumbnail to the percentage of the pieces that have been uploaded... so the image appears to "fade in" as the upload progresses.
It's still in progress at the moment, but you can already try it out if you use a browser that doesn't suck. Specifically, Chrome or Firefox. Opera doesn't yet support the "multiple" attribute on input tags of type file, and neither Opera nor Safari support the onchange event. And, of course, it doesn't work in IE (no surprise there)... even IE 9 Beta. Some of the browsers are starting to support drop zones as well, so at some point I'm going to update this to allow you to drag pictures from a folder to the browser window to upload them. And, as you might expect, I'll eventually bundle this into an extension component and contribute it to OpenNTF... either as part of the core Extension Library or as an addon plugin.
In the context of XPages, this type of functionality is a perfect candidate for progressive enhancement: you can use the context object to determine whether the user's browser supports the feature; if it does, render the fancy component... if not, render a standard, boring file upload control. Hence, all of your users can upload files, but those who use modern browsers experience a far more interactive version of the same feature.
locating XPage components with XspQuery
Sun, Apr 14th 2013 12:00a Tim Tripcony Several years ago, I wrote a utility Java class designed to make it easy to search for components within the current XPage instance based on various criteria. I've found it enormously useful, and, apparently, so has Keith Strickland, because he added it to org.openntf.xsp.extlib, complete with a few refinements. As an example of how you might use this, examine the following line of code:
List requiredFields = new XspQuery()
.loc [read] Keywords: ldd
your how is not your what
Wed, Apr 3rd 2013 11:36a Tim Tripcony I've noticed a pattern emerging when I'm asked for help with XPages. Here's a representative conversation:
"I'm trying to do [X] and it's not working. How can I do that?"
"What are you trying to accomplish?"
"I already told you. I'm trying to do [X]."
"No, that's how you're trying to do it. What are you trying to do?"
For example, replace "[X]" with "reach into a repeat control from outside it" (since this has become the most frequent topic I'm asked about [read] Keywords: xpages application
my new favorite quote
Sat, Mar 23rd 2013 5:20p Tim Tripcony "We go about our daily lives understanding almost nothing of the world. We give little thought to the machinery that generates the sunlight that makes life possible, to the gravity that glues us to an earth that would otherwise send us spinning off into space, or the atoms of which we are made and on whose stability we fundamentally depend. Except for children (who don’t know enough not to ask the important questions), few of us spend much time wondering why nature is the way it is; where the [read] Keywords: wiki
Taking the scary out of Java in XPages: Prologue
Tue, Feb 26th 2013 9:50p Tim Tripcony The discussion following my last post made stark the need for greater availability of information that makes the nature of Java more accessible to Domino developers. Credit for the title of this post goes to Declan, who is considering writing a series of blog posts on this topic. I will be doing the same; hopefully there will be a fair amount of duplication. As David Leedy is fond of stating, it's a good thing when several people share the same information, because that makes it easier for the [read] Keywords: domino
Passthru vs. component - my perspective
Sat, Feb 16th 2013 9:40p Tim Tripcony Paul Withers posted a thorough article explaining the differences between namespaced XPage components (e.g. ) and their corresponding passthru elements (e.g. ), providing numerous examples of what actually happens when these objects are constructed. I've always heard (and often repeated) that passthru elements are more efficiently processed than their namespaced equivalents, so Paul's post inspired me to offer my own perspective.
Simply put, there's practically no difference... but there a [read] Keywords: acl