Monday, November 29, 2010

Recommended video - The Top 5 Mistakes of Massive CSS

I rarely post links, but if you're working with CSS, you really need to watch this video. It contains several great tips that help you write more maintanable CSS.

Monday, November 22, 2010

XPages - Adding non-xpages attributes to input fields

I got a question today from a reader of my blog, regarding input fields, and attributes not available in XPages. He was working with web applications for Apple devices, and needed to add some attributes to input fields that aren't allowed by Domino Designer/XPages.

My workaround kind of reminds me of "old school" domino development, where I often have fields that are HTML, and use hidden fields (hide from web) to capture the value from the browser.

Basically it works like this. The HTML for the input fields is hand typed in the source code. I have a hidden field (xp:inputHidden) for each of the custom fields. In the hidden fields, I've added a custom converter that fetches the value posted from the HTML field using the param map.

To simplify the process of adding custom fields, I've made a custom control with two parameters, fieldName and attributes. The field is bound to currentDocument[ compositeData.fieldName ], and the html field is rendered in a computed field (xp:text), where the attributes are added. I'm terrible at explaining code, so take a look at the provided demoapp to see what I mean :)

In the demoapp, I've created a simple form with HTML5 controls. You need Opera or Safari to view the controls properly.

Screenshots from Opera:

I don't recommend this technique unless you really need it. If possible, use JavaScript in the browser to set the attributes instead. This way, you can still take advantage of the power of XPages.

>> Download demoapp

Tuesday, November 16, 2010

XPages Demoapp - Adding controls to a pager

I got a question from a reader regarding posting a demoapp of Adding controls inside a pager

I mocked up a simple demoapp with search controls inside the pager area.

>> Download demoapp

Wednesday, November 10, 2010

NotesDocumentCollection.stampAllMulti and readers fields

Update 11.11.10: I did a little test, and it looks like the bug(?) affects Readers, Authors and Names fields.

Readers fields (isReaders=True) in the "template" document seems to be set as Text fields in the stamped documents.

It wasn't a critical bug(?) for me, but I thought I should share it.

Only tested on Domino 8.5.2

Monday, November 8, 2010

Enable enhanced HTML generation via LotusScript

I have about 850 applications that now needs enhanced HTML generation enabled. As far as I know, the only way to enable this in an application is via LS or manually.

Here's example code for enabling it with LS for one db:
Dim s As New NotesSession, db As NotesDatabase
Set db = s.currentDatabase

'// Fetch the db icon document
Dim col As NotesNoteCollection, doc As NotesDocument
Set col = db.createNoteCollection( False )
col.selectIcon = True
Call col.buildCollection()

'// Enable enhanced HTML
Set doc = db.getDocumentById( col.getFirstNoteId() )
Call doc.replaceItemValue( "$AllowPost8HTML", "1" )
Call True, False )
I found the solution here.

Friday, November 5, 2010

New blog design

I've decided to ditch the standard green template, and go for a cleaner look.
I modified the template I chose slightly to fit my requirements. I was expecting several hours to find/create a suitable look, but the process took about an hour total.

Hopefully it will make the content more readable.

Thursday, November 4, 2010

XPages: Obscure error message for undeclared variable

I've had an error message that popped up regularly in our logs. Script interpreter error, line=524, col=25: Interpret exception
The line it refers to has a for .. in loop on a scoped variable. I believed it had to do with the object being in a scoped variable, and tried to make a by-value copy. That didn't help.

I finally (!!) discovered the reason for the error message. I had forgotten to declare the "key" variable.
// Results in error
for( key in object ){ .. }
// OK (key can also be declared outside loop)
for( var key in object ){ .. }