I think I have my view rendering problem licked. To recap, I've been working on a way to show views in XPages that met a couple requirements:
Entirely dynamic. Since this will be for a combined reporting site that will show views from customized project databases of wildly varying needs, I couldn't make any assumptions about view layout, categorization, or content. It should pull as much display information from the view design as possible.
Fast. Some of these views have thousands of rows, so it should be as fast as possible to load from the database and render for the browser.
Pagination. Though I don't really like pagination for the average case (who wants to look at a 40-row view 30 rows at a time?), sending thousands of table rows to a browser causes a miserable experience even when that browser isn't IE.
Full-text searching and other Domino goodies. I don't want it to be a pain to just be able to search through a view like you would in the Notes client.
Support for "second tier" Domino view features. I use special text, column hide-when formulas, "show values in this column as links", Notes-style [<span>pass-through-HTML<span>], and color columns constantly.
Of these, 1 and 5 are the most important.
I considered changing my custom HTML code to instead create a bunch of Java objects to make pagination easier, but performance would be an issue - it's tough to beat built-in controls for raw speed. As anyone who has looked at the code for the mail template knows, IBM/Lotus cheats like crazy, and often the only thing you can do is to just go with what they've done and beat it into shape. Thus, the answer came to me: customizer beans for the ExtLib's dynamic view panel.
The dynamic view panel has a "customizerBean" property that takes a string class name of a bean to create to hook into a couple overridable methods and events:
ViewFactory getViewFactory() - this lets you override how the panel pulls in all of its information about the view.
boolean createColumns(FacesContext context, UIDynamicViewPanel panel, ViewFactory f) - this lets you override how the panel uses the gathered view information to generate the list of data table columns (or simply run code before that happens, if it returns false)
IControl createColumn(FacesContext context, UIDynamicViewPanel panel, int index, ColumnDef colDef) - similarly, this lets you change the way each individual column is created based on the ColumnDef (an object generated by your ViewFactory)
afterCreateColumn(FacesContext context, int index, ColumnDef colDef, IControl column) - this is an event fired after each column is generated, allowing you to customize the generated column without having to build it from scratch
afterCreateColumns(FacesContext context, UIDynamicPanel panel) - similarly, this lets you run code after the column creation is done
These events provided just the hooks I needed to get the dynamic panel to do what I wanted.
To add special text support, I added an implementation of afterCreateColumn(...) that replaced the column's default ViewColumnConverter with my own subclass that overrides getValueAsString(...). With that, I can walk up the current component's ancestors to find the panel, find the individual ViewEntry's variable name from there, and use that to process the special text properly.
Column Hide-When Formulas
These are a bit trickier. The getViewFactory() hook lets me provide my own subclass of DefaultViewFactory, but there's a reason that the dynamic view panel doesn't support these formulas by default: they're not exposed by the NotesViewColumn class. The two ways I can think of to get at this information are the C API (or otherwise reading the design information from the view note directly) and DXL. The former is no doubt significantly faster, but DXL is much, much easier and is good enough for my needs at the moment. So I export the view as DXL and process its column nodes and their children. Then, for each with a hide-when formula, I evaluate the formula in the context of a new document in the project's database and use the result to set the column-hidden flag.
"Show values in this column as links"
This goes hand-in-hand with the hide-when formulas. The column nodes in the DXL have a showaslinks attribute that I can look for to set this flag.
Much like special text, once I have the custom converter attached to the column, I can break apart and reassemble text values on [< and >] and XML-encode the non-HTML bits. While I'm attaching the converter, I set the column's content type to "html", since I'll be handling the encoding.
These are... tricky, and I'm not yet proud of my fix. There are two problems: getting each cell to know about its color information from previous cells and then actually applying that color information.
For the former problem, I dealt with it by adding an "activeColorColumn" property to the ColumnDef object and setting it to the programmatic name of the most recent color column before each column.
If I get that last bit of code cleaned up to a point where I'm comfortable letting people see it, I'll post my example code. In the mean time, I'll count this whole thing as a win for only writing the code you need to and letting the platform take care of the rest.
Public Service Announcement - NotesIn9 is down.
Tue, May 7th 2013 11:16a Jesse Gallagher David Leedy has run into some trouble with NotesIn9.com being down and he asked
if I could help him get the word out about it, which I'm more than happy to do:
Hi - Just wanted to drop a note out there about my NotesIn9.com website.
Currently it's redirecting to someplace else for some unknown reason. I
assume it's been php hacked but I don't know.
My Wordpress site is generously hosted by Chris Miller and I've sent him a
note. Though since he's in the middle of the [read] Keywords: xpages bug
Java Traps and Misconceptions
Tue, Apr 23rd 2013 6:16a Jesse Gallagher I wrote a post over at the Social Biz UG site covering a number of traps and
conceptual hurdles I frequently see people running into when it comes to Java:
ang=en_us [read] Keywords: java
Fun With Old XML Features
Tue, Apr 2nd 2013 11:18p Jesse Gallagher One of the side effects of working on the OpenNTF Domino API is that I saw
every method in the interfaces, including ones that were either new to me or
that I had forgotten about a long time ago. One of these is the "parseXML"
method found on Items, RichTextItems, and EmbeddedObjects. This was added back
in 5.0.3, I assume for some reason related to the mail template, like
everything else added back then. Basically, it takes either the contents of a
text item, the text of a rich text ite [read] Keywords: domino
Release M1 of org.openntf.domino
Tue, Apr 2nd 2013 9:17p Jesse Gallagher Yesterday, we released milestone 1 of our improved Domino API. This is our
first tagged release meant for proper testing - all of the classes are
implemented, many of the banner features are in there, and we've been using it
in various real-world situations. I switched a couple of my side projects over
- my portfolio site, the code for this blog (though I haven't deployed the
template yet), and a couple personal game-related apps. That kind of testing is
going to be crucial in getting us [read] Keywords: domino
A Mini-Vacation With Ruby and the Domino Data Service
Sat, Mar 2nd 2013 4:11p Jesse Gallagher Since I've been neck-deep in LotusScript and Java for the past couple weeks, I
decided to take a bit of a sanity break today and play around with Ruby.
Specifically, I wrote a skeletal wrapper for the Domino Data Service in the
ExtLib and the first steps of a Rails app using it a bit. I don't expect this
to actually be useful down the line, or even necessarily to get any more work
put into it, but it was a fun diversion.
The API takes the same general shape as the normal Domino API, exce [read] Keywords: domino
I Know Some Guys
Tue, Feb 26th 2013 12:09p Jesse Gallagher I've been a bit quiet lately, but that's mostly because I've been pretty busy
lately. After my old company began closing down, I started going whole-hog in
my consulting company, I Know Some Guys. Naturally, I can't go TOO much into
it, but the general gist is "so far, so good." We have a couple clients so far
and they've been keeping me busy indeed. A lot of that has involved classic
Notes client and web development, but I guess that serves me right for
snickering at people work [read] Keywords: domino
The Bean-Backed Table Design Pattern
Tue, Jan 22nd 2013 4:13p Jesse Gallagher First off, I don't like the name of this that I came up with, but it'll have to
One of the design problems that comes up all the time in Notes/Domino
development is the "arbitrary table" idea. In classic Notes, you could solve
this with an embedded view, generated HTML (if you didn't want it to be good),
or a fixed-size table with a bunch of hide-whens. With XPages, everything is
much more flexible, but there's still the question of the actual implementation.
The route I've bee [read] Keywords: domino