This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Jul 21, 2011, 8:50 PM
14 Posts

Re: Multi-line text wrapping

  • Category: Other
  • Platform: Not Applicable
  • Release: 8.5.2
  • Role: Developer
  • Tags: formatted text string new line wrapping
  • Replies: 17
Thanks a lot for your suggestions, Judy.  I had seen your posts about this problem on the other forum.
 
Unfortunately, the data is stored in a text field, not multivalue.
 
The big problem is not the line breaks, but the wrapping.
 
What works, but seems primeval, is in the source doc field replacing @NewLine with <BR>, and replacing " " with some character (I use ^^).  Then in the Xpage I use a computed field rendering html (that recognizes the <BR>'s and gives me the line breaks), and do value.replace("^^", " ").
 
Really, it seems ridiculous to me to have to resort to such lengths, but it's the only combination, out of the zillions I've tried, that works.
Jul 22, 2011, 12:53 PM
31 Posts
Re: Multi-line text wrapping
I know what you mean about the weird breaking on spaces & stretching beyond the window -- that's why I ended up doing what I did, changing the form field to be multi-values.  I'll give your solution a shot the next time I bump into this -- thanks!
 
But I wonder if you couldn't just use the converters & instead of doing:
 
                    <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>
 
you could do something like this:
 
                        <xp:this.converter>
                            <xp:customConverter>
                                <xp:this.getAsObject><![CDATA[#{javascript:@Explode(value,"\n");}]]></xp:this.getAsObject>
                                <xp:this.getAsString><![CDATA[#{javascript:@Replace(@Implode(value,"\n");" ";"&nbsp;");}]]></xp:this.getAsString>
                            </xp:customConverter>
                        </xp:this.converter>
 
Not sure if you'd have to alter the getAsObject part as well to get it back into the Notes field properly.  Haven't tried this so I don't know if it would work.
Jul 22, 2011, 6:51 PM
14 Posts
Re: Multi-line text wrapping
Took your suggestion, and tried the @Replace(@Implode(value,"\n");" ";"&nbsp;") in the custom converter.  Had the same problem with the line-wrapping.
Jul 22, 2011, 6:18 PM
14 Posts
Re: Multi-line text wrapping
I'm wondering if there's something other than getItemValueString to use to import the text... that method strips out all formatting...
Jul 25, 2011, 2:42 PM
298 Posts
GetItemValue?
You could try getItemValue but remember that returns a vector. I am not sure if that will do anything different than the getItemValueString, let us know... Howard
Jul 25, 2011, 7:08 PM
14 Posts
Re: GetItemValue?
Unfortunately, getItemValue yields the same results:  line breaks ignored.
 
When I "View Source," the text is formatted perfectly.  But not in the browser display itself.
Jul 26, 2011, 4:22 PM
31 Posts
My last post on this issue ...
First, make sure you aren't in compatibility mode in IE.  Compatibility mode can wreak havoc with CSS & the box model.  I would test this strictly in Firefox & use Firebug to look at the source when it's rendered.
 
And, lastly, you know what I'm going to say ... Since a single-value text field with embedded line breaks is causing you such grief during display, you really may have to consider at least temporarily storing it in a proper multi-value text field for display/editing -- you can save it back to your single-value text field on save.
 
I'm done.
Jul 26, 2011, 8:33 PM
14 Posts
Re: My last post on this issue ...
Thanks so much for everyone's help!
 
I tried storing the formatted text in a Rich Text field.  The carriage returns displayed on the web, but spaces and bolding were added randomly.
 
So my final solution was:
 
1) In the Notes form, added Input Translation to the text field that replaced @NewLine with "<BR>" and blank spaces with "^"
 
2) In the Xpage, used a Computed Field (HTML) that replaced the "^" with a blank space.
 
var temp=AnalysisDoc.getItemValueString("Representation");
temp.replace("^", " ");
 
The formatting comes across perfectly now.
Jul 27, 2011, 7:38 AM
261 Posts
Re: My last post on this issue ...
Hello Sally,
 
It's good to read you found a solution that works for you, although I can imagine that changing the data itself isn't what you really want.
 
I just wanted to see for myself how this worked so I created a (Notes) form with a single text field (not multi-value), added some text with line breaks and displayed it in a computed field on an XPage (added the document as a data source and used doc.getItemValue to read the data in the computed field).
 
The solution you described in your fist post worked for me: there were no &nbsp; added at all and the line breaks were displayed correctly. Here's the code I've used:

    <xp:text escape="false">
        <xp:this.converter>
            <xp:customConverter>
                <xp:this.getAsString><![CDATA[#{javascript:@ReplaceSubstring(value, "\n", "<br />")}]]></xp:this.getAsString>
                <xp:this.getAsObject><![CDATA[#{javascript:@ReplaceSubstring(value, "\n", "<br />")}]]></xp:this.getAsObject>
            </xp:customConverter>
        </xp:this.converter>
        <xp:this.value><![CDATA[#{javascript:document1.getItemValue("name")}]]></xp:this.value>
    </xp:text>

 
 Mark
 
(BTW: I've used Domino/Notes 8.5.2FP3)
Aug 2, 2011, 6:15 PM
14 Posts
Mark's solution
Thanks, Mark!  When I saw your post I thought, "Haven't I already tried that combination?", but then tried it again, and it worked perfectly.
 
I'm new to Xpages, and think I lost confidence and started flailing around early instead of just calming down and figuring out the elements.
 
SO MUCH BETTER than messing with the data... thanx mucho mucho for taking the time to work through it and respond.
 
Sally

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal