Welcome to the IBM Collaboration Solutions Community IQJam.
UsernamePassword
Reset Password | Register
   
Home | Leader Board | Tags | Help
How do you display multi-line text data in read mode? 
In an XPage app I have a multi-line editbox that is bound to a text field in a legacy database.  When in editmode it works fine.  But if I try to put the XPage into read mode then the text from the document doesn't display correctly.  It seems that every space in the text is rendered with a non-breaking space.  &nbsp.  So it's not wrapping correctly.
 
I tried hiding my multi-line edit box when the xpage is on read mode and attempted to use a label and computed field to display the data from the doc.  I did not get and nbsp's but I lost all formatting - line breaks, tabs, etc... 
 
What's the correct way to display a multi-line text field in Read mode? 
Domino Development / XPages
David Leedy - about 1 year ago |  |  | Viewed 761 times

There are 3 answers

1votes
I see what you mean. What works for me is setting the multipleSeparator property to computed javascript
(!document1.isEditable()) ? "<br />" : "" 
 
As I'm sure you'll realise, Dave, this will separate values with a new line in read mode and should mean there is no multiple value separator in edit mode.
 
The caveat is that I've not tried that in an actual app, so it may or moy not have knock-on implications. Any better alternative is welcome.


Paul Withers - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
I would have done it with an edit box and a separate computed field, with mutually exclusive visibility.  However, I like Paul's method a lot better!  If anyone knows any caveats to Paul's technique, please comment.


John Smart - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


1votes
I've found that using the field's 'converter' is the best solution.
 
Each field that is bound to a data source contains a 'converter' property that includes two methods that you can code.  One is called 'getAsObject' and the other is getAsString.
 
 For example, I have a multi-value field that displays one entry per line. 
 
My getAsObject contains
MisUtil.trimUnique(value.split('\r\n')))
And my getAsString contains

MisUtil.join(value, '\r\n')

 



Bill Hanson - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community