0

I want to work with long strings (size minimum: 100kb) on Xpages. I assume the best method to store a large string is in a data field of the type "Rich Text". Right now I am stuck with the data handing of this string. How can I transfer this string between server and client?

So far I tried:

  • data binding controls: Rich text field (Problem: formats the text, tags), text field (Problem: does not work after a certain size)

  • implementing a rest service: The response body will be cut off at a certain point

     <xe:restService pathInfo="getTestString">
     <xe:this.service>
         <xe:customRestService>
             <xe:this.doGet><![CDATA[#{javascript:var id = context.getUrlParameter("documentId");
             session.getCurrentDatabase().getDocumentByID(id).getItemValueString("test");}]]></xe:this.doGet>
         </xe:customRestService>
     </xe:this.service>
    </xe:restService>
    
    
    var url = new URL(window.location.href);
    var documentId = url.searchParams.get("documentId");
    xhr.open('GET', './rest.xsp/getTestString?documentId=' + documentId, true);;
    xhr.send(null);
    xhr.response;
    

So I was wondering whether I missed out on a configuration of my REST Service. Which other alternatives are available to transfer large data between client and server on Xpages?

lucas
  • 55
  • 2
  • 10
  • There are 2 questions here: how to store a large text/ string in a Notes database and how to transfer that to the client. Not sure if you should use a rich text field: I think Notes automatically inserts paragraph chars that might break your text. A standard text field has a size limitation, but maybe you can use the org.openntf Domino API (ODA) that will automatically serialise a large text into an attachment. I'm not aware of a size limit when reading data through an XPages REST service: might cut off because you're using getItemValueString() in the example. – Mark Leusink Jul 01 '21 at 11:03
  • Thanks for your answer. Is there an alternative for getItemValueString() that should work? – lucas Jul 01 '21 at 13:12

1 Answers1

2

I tested your scenario. doc.getItemValueString() only reads 64 KB of data from the rich text field. If you want all data you can use (in SSJS):

var doc = database.getDocumentByUNID(id);
var item:NotesRichTextItem = doc.getFirstItem('test');
return item.getUnformattedText();

Looks like that method return the exact text from the rich text item, no paragraph characters are inserted.

Mark Leusink
  • 3,747
  • 15
  • 23
  • Hey, I am sorry for following up so late. I had a break for the last couple days. I tried out your approach, but it did not work out quite right for me. Yet, I found out about Domino Access Services. For my GET requests it works perfectly fine. I can retrieve my values from the JSON format without any restrictions (at least so far). My problem right now is that the POST requests seem to have a size limit. So right now I am trying to figure out to fix these restrictions for my POST requests. – lucas Jul 16 '21 at 12:53