Tuesday, June 22, 2010

XPages: Adding default value for empty view columns

Go to source mode, and find the column you want to add the default text. Add a computed field that's rendered when:
!( this.getParent().getValue() )

E.g.
<xp:viewColumn columnName="notes" id="colNotes">
<xp:viewColumnHeader value="Notes"></xp:viewColumnHeader>
<xp:text value="No notes"
rendered="#{javascript:return !( this.getParent().getValue() );}" />
</xp:viewColumn>

this.getParent() returns the cell. If the cell has no value, the computed field is visible.

You can achieve the same in the Notes column for the view (@If...), but I don't like mixing data and presentation.

0 comments: