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



Aug 10, 2011, 5:59 AM
2 Posts

Working with Rich Text Lite Thumbnail Fields

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: Thumbnail Rich Text Lite
  • Replies: 2
I'm relatively new to the xPages world, so if there are better way of doing the following I'd be happy to learn.... 
 
I wanted to display the Rich Text Lite Thumbnail fields in my xPages, both the View and Documents. The following is my solution.
 
RTL Thumbnails are saved as an attachment as defined in the field properties, "image attachment name"
 
For this example lets say we've set that to "thumbPic.jpg"
 
 
VIEWS 
 
To display these in a view you need to have a column in your view which displays the UNID of the document. Use the formula @Text(@DocumentUniqueID).
You should also set the Name of the column In the Programatic Use to something like "unid" - you'll reference this later.
 
In your xPage, select your view as a data source and import the columns you neeed, including the "unid" one.
 
Select the unid column and change the Data selction from "view Column" to   "Computed Value". Use the following SSJS. Adjust as required.
 

var myView = "0" //dummy view name work just as well as view unid

var myDoc = viewEntry.getColumnValue("unid") // this is a column with the reference 'unid'

var thumbName = "thumbPic.jpg" //hardcoded value in the rich text lite field

return "<img src='./" + myView + "/" + myDoc + "/$File/" + thumbName + "' WIDTH=50 HEIGHT=50>"

All going well when you display your view in the xPage on the web you should see the images. 
 
 
OPENING DOCUMENTS 
 
Select your form containing the RTL Thumbnail field as your datasource.  
 
Add an Image Control to your xPage. Change the Image Source to Computed.
 
Use the following SSJS 
 

var myView = "0" //dummy view name work just as well as view unid

var myDoc = param.get("documentId") // this is the URL parameter which

is the unid of the doc.

var thumbName = "thumbPic.jpg" //hardcoded value in the rich text lite field

return "/" + myView + "/" + myDoc + "/$File/" + thumbName

 

 
Now when  you open the document, say from the view, the thumbnail displays.
 
This solution only works with xPages on the web - note sure why it won't work in the client yet.  
 
Anyway, hope this is helpful. 
  
Aug 10, 2011, 11:24 AM
8 Posts
Re: Working with Rich Text Lite Thumbnail Fields
 Seems like a good solution. Thanks for the post.
Aug 13, 2011, 1:22 AM
2 Posts
Re: Working with Rich Text Lite Thumbnail Fields
Found out why the code didn't work in the client. It seems that the client expect a completly different URL Format.
Why IBM did it that way is anyones guess... 
Here's an updated SSJS for the view display. 
 

(Code for the notes client version adapted from http://www.wissel.net/blog/d6plinks/SHWL-86QKNM)

var dbpfx

var myView = "0" //dummy view name

var myDoc = viewEntry.getColumnValue("unid") // this is a column with the reference 'unid'

var thumbName = "thumbPic.jpg" //hardcoded value in the rich text lite field

if (@ClientType()=="Web")

{

// web version

var mydb = @Left(session.getHttpURL(),".nsf")

 

if (@Length(mydb) == 0)

{

dbpfx = context.getUrl().getPath()

}

return "<img src='" + dbpfx + myView + "/" + myDoc + "/$File/" + thumbName + "' WIDTH=100 HEIGHT=100>"

}

else

{

//Notes Client version

var curURL = context.getUrl();

var curAdr = curURL.getAddress();

var rel = curURL.getSiteRelativeAddress(context);

var step1 = curAdr.substr(0,curAdr.indexOf(rel));

// Now cut off the http

var step2 = step1.substr(step1.indexOf("//")+2);

var base = step2.substr(step2.indexOf("/"));

var middle = "/xsp/.ibmmodres/domino/OpenAttachment";

if (base.substr(0,4) == "/xsp") {

middle += base.substr(4);

} else {

middle += base;

}

var result = base + middle + "/" + myDoc + "/$File/" + thumbName + "?Open";

return "<img src='" + result + "'/>";

}

 

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