329 Lotus blogs updated hourly. Who will post next? Home | Downloads | Events | Jobs | Twitter | Bookmarks | Pods | Blogs | Search | myPL | About 
 
Latest 7 Posts
How I Got XPiNC Run-On-Server With SSO Working
Fri, May 17th 2013 168
Public Service Announcement - NotesIn9 is down.
Tue, May 7th 2013 329
My Latest Programming-Technique Improvements
Tue, Apr 23rd 2013 190
Java Traps and Misconceptions
Tue, Apr 23rd 2013 188
Fun With Old XML Features
Tue, Apr 2nd 2013 220
Release M1 of org.openntf.domino
Tue, Apr 2nd 2013 207
We Have The Technology: The org.openntf.domino API
Thu, Mar 21st 2013 209
Top 10
"Controller" Classes Have Been Helping Me Greatly
Wed, Dec 26th 2012 683
Putting Apache in Front of Domino
Sat, Dec 8th 2012 677
Programming Tips: Implied Booleans and the Ternary Operator
Tue, Dec 11th 2012 488
Moving From Ruby-in-XPages to Polyglot
Wed, Dec 12th 2012 479
More On "Controller" Classes
Mon, Jan 7th 2013 448
Quick-and-Dirty CKEditor Toolbar Setup for XPages
Tue, Sep 4th 2012 382
Building XPages servlets with FacesContext access
Thu, Sep 6th 2012 338
Faking Sortable View Data
Sun, Jul 22nd 2012 336
Public Service Announcement - NotesIn9 is down.
Tue, May 7th 2013 329
My Current Data-Source Musings
Mon, Nov 26th 2012 309


Enhancing xe:dynamicViewPanel For My Own Purposes
Jesse Gallagher    

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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 originally wrote my own code to generate a big HTML blob for the view, which was perfect on points 1 and 5 (and looked great, since I converted categories to OneUI sections), but wasn't as hot on the other points. The Extension Library's xe:dynamicViewPanel control hits points 1 through 4 with aplomb, but misses the crucial point 5. For one crazy moment, I toyed with the idea of trying to get the output of the "legacy" HTML view renderer (which is perfect on all points) via client-side JavaScript or some other hack, but decided against it as being too rickety.

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.

Special Text

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.

Pass-through-HTML

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.

Color Columns

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. The latter is the ugly part. You can't just set the column's style, since that will apply to the entire column and make a fine mess of everything. What you really want to do is assign it to the current <td> element, but I don't know a good way to do that. In the mean time, I've hacked around it by making a hidden <div> in each cell with the style tucked into a data-cell-style attribute. Then, I have some client JavaScript look for these divs and apply their styling to the parent table cell. It's not pretty, but it works for now.

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.



---------------------
http://frostillic.us/?p=269
Feb 09, 2012
256 hits



Recent Blog Posts
168


How I Got XPiNC Run-On-Server With SSO Working
Fri, May 17th 2013 5:14p   Jesse Gallagher
Among the new features in Domino 9 is this little guy, found on the Launch pane of a database's properties when you set it to open an XPage: If you've ever used an XPiNC application before, you'll know this is a godsend, promising the vast performance benefits of running an app on a server combined with the "the users are stuck using the Notes client" benefits of XPiNC. I turned this on for a new app on one of my client's servers (let's say the server name is ClientName-2/ClientNa [read] Keywords: admin domino notes notes client policies sametime xpages application database desktop network properties server
329


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
190


My Latest Programming-Technique Improvements
Tue, Apr 23rd 2013 9:18a   Jesse Gallagher
Over the past couple weeks, I've been trying out some new things to make my code a bit cleaner and I've been having a good time of it, so I figured I'd write up a quick summary. Composed Method First and foremost, I've been trying out the Composed Method of programming. This is not a new idea - indeed, it's a pretty direct application of general refactoring - but the slight perspective change from "factor out reused code" to starting out with clean, small blocks has been a pleasan [read] Keywords: agent domino ibm lotusscript xpages application database eclipse java openntf
188


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: https://www.socialbizug.org/blogs/gidgerby/entry/java_traps_and_misconceptions?l ang=en_us [read] Keywords: java
220


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 ibm notes rich text xpages java javascript openntf xml
207


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 openntf
209


We Have The Technology: The org.openntf.domino API
Thu, Mar 21st 2013 7:13p   Anonymous
As Nathan and Tim posted earlier today, a number of us have been working recently on a pretty exciting new project: the org.openntf.domino API. This is a drop-in replacement/extension for the existing lotus.domino Java API that improves its stability and feature set in numerous ways. The way I see it, there are a couple main areas of improvement: Plain Old Bug Fixes doc.hasItem(null) crashes a Domino server. That's no good! We've fixed that, and we're going through and fixing other [read] Keywords: agent domino dxl lotus notes bug database java openntf server xml
257


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 lotusscript database java server




270


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 notes notes client consulting database development
293


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 do. 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 notes xpages database development java




Created and Maintained by Yancy Lent - About - Blog Submission - Suggestions - Change Log - Blog Widget - Advertising - Mobile Edition