Thursday, April 14, 2011

Simple trick to format XPages Checkbox group

If you put display:inline on a table (which XPages generates for a CheckboxGroup), you can style each cell like an inline element.

To make a four column checkbox group (put fourColumnCheckboxGroup as styleClass on the xp:checkBoxGroup), put this in your CSS file:
.fourColumnCheckboxGroup { display: inline; }
.fourColumnCheckboxGroup td { float: left; width: 24%; }

For three columns, use 32% and so on. I use (100 / numberOfColumns) - 1 as that seems to work best cross browser.

Share and enjoy :)

Tuesday, April 5, 2011

Add a custom footer to a ViewPanel column

Open the XPage in source mode. Set the pointer inside <xp:this.facets>. Create a panel, div, output text or whatever with the attribute xp:key="footer", and the content will be showed at the bottom of the column.

E.g.
<xp:text value="#{viewScope.totalsForSomeColumn}" xp:key="footer" />

Monday, March 28, 2011

Small bugfix in the CKEditor integration for XPages demoapp

When you tried to upload more than one file at once (e.g. one attachment and an image), only the first file uploaded successfully.

This bug has now been fixed.

The Domino part of the demo requires Dojo 1.4.1 (Domino 8.5.2 server), as it's hard coded in the HTML header. Modify it to suit your environment.

>> Download demoapp

Thursday, March 3, 2011

Repeat Controls and Multivalue fields

There was a small discussion over at Julian's blog regarding multivalue fields and repeat controls. I knew that it was possible to bind Javascript objects and arrays to input fields inside a repeat control using EL syntax.

I got a little curious, and decided to test if the same was possible for a multivalue field. It turns out it's just as easy.

Instead of my regular demoapps, I'll post source code for the test XPage I made. It's bound to a form with one field, named field (don't name any field field in real applications!!).

To test it, create a form named Test with a field named field. Create an XPage/paste the source code from the file below. Click the add-button to add an item in the multivalue field. Save the document to test if it works. Not sure how many versions back this works with.

Demo XPage source code

Wednesday, March 2, 2011

RepeatControls troubles - solution repeatControls

I've struggled more or less a working day trying to figure out why all of the properties I passed to a Custom Control inside a Repeat Control got nullified.

In afterPageLoad, in the Custom Control, I tried binding the compositeData values to a private variable for later use. I tried a lot of ways of making the properties survive, but whatever I tried, they ended up as null values before I could get a hold of them.

Components inside the control could "read" the composite data, but when the life cycle got as far as scripting, the values were nullified. The solution it turns out is setting the property repeatControls on the Repeat Control to true. I guess this results in a less agressive trash collector(?).

Anyways, my recommendation to IBM is to default set the option to true, unless the performance hit is big. I bet I'm not the only developer that has struggled/will struggle with this strange behaviour.

Monday, February 14, 2011

Small update on the EventDelegator demo - onChange implemented

I don't know if anyone is using my EventDelegation technique for custom events.

In case any of you do, I've updated the demo/script in the demoapp. You can now also delegate onChange events.