XPages: multiline edit box - how to calculate height?

This is a bit of a solution, followed by a question –

Solution part:

I’ve got a multiline EditBox control with NO multiple separator defined for it, bound to a multi-value TEXT field that has only “New Line” allowed as a separator.

Following various posts & suggestions & trial & error, in EDIT mode, I’m using a custom converter:

xp:this.converter

<xp:customConverter>

	<xp:this.getAsObject><![CDATA[#{javascript:@Explode(value,"\n");}]]></xp:this.getAsObject>

	<xp:this.getAsString><![CDATA[#{javascript:@Implode(value,"\n")}]]></xp:this.getAsString>

</xp:customConverter>

</xp:this.converter>

that is presenting and saving the data properly, breaking on the carriage returns.

.

However, in READ mode, the display didn’t always honour the carriage returns, and sometimes broke in the weirdest places. Following Co’s advice, http://www-10.lotus.com/ldd/nd85forum.nsf/5f27803bba85d8e285256bf10054620d/377dd67e599c192f85257707002fb5ce?OpenDocument

I’ve resorted to using a separate computed field, displayed as HTML, for READ mode display, using the formula:

doc = document1.getDocument();

@Implode(doc.getItemValue(“Product”),“
”);

All in all, a bit much to get a simple multiline TEXT field to behave, but it works.

Question part:

In READ mode, the display adjusts fine to accommodate the field contents.

How do I calculate the height though for the EDIT mode (multiline Edit Box) to account for lines that wrap, etc. ?

This is what I’ve got so far (using EMS as the UNIT of the Edit Box height):

doc = document1.getDocument();

@Count(doc.getItemValue(“Product”))+4; // I used 4 as a buffer to account for L-O-N-G lines that wrapped… kinda kludgey.

Anyone have a better suggestion?

I’ve tried just leaving it set at AUTO but that really squashed the height & resulted in vertical scroll-bars on the right hand side, and I’d like to avoid that if possible.

Thanks!