Examples
Convert different values to strings:
String(new Date());
String("12345");
String(12345);
Definition and Usage
The String() method converts a value to a string.
Note
The String() method returns the same as the toString() method for any value.
Syntax
Parameters
ParameterDescriptionvalueRequired.A JavaScript value.
Return Value
TypeDescriptionA string.The value converted to a string.Browser Support
String() is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
ChromeEdgeFirefoxSafariOperaIEYesYesYesYesYesYesMore Examples
Examples
Convert different values to strings:
String(Boolean(0));
String(Boolean(1));
String([1,2,3,4]);
Call this method to convert a RichTextItem to an HTML string. The form of the HTML created is similar to what is produced by the Domino® web server and sent to the client. Parameters that guide how the conversion is done can be supplied by a Vector of Strings (Java™) or an array of strings (LS). After this method is called, the getHTMLReferences (RichTextItem class) method can be called. This call returns a Vector (Java™) or array (LS) of HTMLReference objects. Each reference object has a Type property, which may be queried to determine how to interpret the data contained within the reference. The HTMLReference class was created to represent the data contained within an HTML reference.
Defined in
NotesRichTextItem
Syntax
public Strings ConvertToHTML(Vector Options) throws NotesException;Parameters
ParameterDescriptionOptionsVector. A vector which includes the parameters list for converting.Return Values
Return valueDescriptionVectorVector. The strings of HTML converted from the RTF field content.Possible Exceptions
Possible exceptionsDescriptionHTML conversion error (4835)The operation failed to convert RTF content to HTML.Language cross-reference
Converttohtml in LotusScript® NotesRichTextItem class
ConvertToHTML in JavaScript™ NotesRichTextItem class
Example
This example shows how to use this method to convert a RichTextItem to an HTML string:
import java.util.Date; import java.util.Vector; import lotus.domino.*; public class JavaAgent extends AgentBase { public void NotesMain() { try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); Database db = session.getCurrentDatabase(); DocumentCollection col = db.getAllDocuments(); Document doc = col.getFirstDocument(); RichTextItem rt = (RichTextItem) doc.getFirstItem("RTF"); String ret = "Convert RTF to HTML on"+(new Date()).toString()+"\r\n"; ret = ret + rt.ConvertToHTML(null); Vector refs = rt.getHTMLReferences(); if(!refs.isEmpty()){ for(int i =0; i< refs.capacity();i++){ HTMLReference ref = (HTMLReference) refs.get(i); ret = ret + "\r\n"; ret = ret + "Refrence Number:" + i +"\r\n"; ret = ret + "Type ID:"+ ref.getType() +"\r\n"; ret = ret + "Command ID:"+ ref.getCommandID() +"\r\n"; ret = ret + "URL:"+ ref.getURL() + "\r\n"; ret = ret + "FileName:"+ ref.getFileName() + "\r\n"; ref.extractFile("C:\\kkk.gif",true); } } System.out.print(ret); } catch(Exception e) { e.printStackTrace(); } } }Call this method to convert a RichTextItem to an HTML string. The form of the HTML created is similar to what is produced by the Domino® web server and sent to the client. Parameters that guide how the conversion is done can be supplied by a Vector of Strings (Java™) or an array of strings (LS). After this method is called, the getHTMLReferences (RichTextItem class) method can be called. This call returns a Vector (Java™) or array (LS) of HTMLReference objects. Each reference object has a Type property, which may be queried to determine how to interpret the data contained within the reference. The HTMLReference class was created to represent the data contained within an HTML reference.
Defined in
NotesRichTextItem
Syntax
public Strings ConvertToHTML(Vector Options) throws NotesException;Parameters
ParameterDescriptionOptionsVector. A vector which includes the parameters list for converting.Return Values
Return valueDescriptionVectorVector. The strings of HTML converted from the RTF field content.Possible Exceptions
Possible exceptionsDescriptionHTML conversion error (4835)The operation failed to convert RTF content to HTML.Language cross-reference
Converttohtml in LotusScript® NotesRichTextItem class
ConvertToHTML in JavaScript™ NotesRichTextItem class
Example
This example shows how to use this method to convert a RichTextItem to an HTML string:
import java.util.Date; import java.util.Vector; import lotus.domino.*; public class JavaAgent extends AgentBase { public void NotesMain() { try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); Database db = session.getCurrentDatabase(); DocumentCollection col = db.getAllDocuments(); Document doc = col.getFirstDocument(); RichTextItem rt = (RichTextItem) doc.getFirstItem("RTF"); String ret = "Convert RTF to HTML on"+(new Date()).toString()+"\r\n"; ret = ret + rt.ConvertToHTML(null); Vector refs = rt.getHTMLReferences(); if(!refs.isEmpty()){ for(int i =0; i< refs.capacity();i++){ HTMLReference ref = (HTMLReference) refs.get(i); ret = ret + "\r\n"; ret = ret + "Refrence Number:" + i +"\r\n"; ret = ret + "Type ID:"+ ref.getType() +"\r\n"; ret = ret + "Command ID:"+ ref.getCommandID() +"\r\n"; ret = ret + "URL:"+ ref.getURL() + "\r\n"; ret = ret + "FileName:"+ ref.getFileName() + "\r\n"; ref.extractFile("C:\\kkk.gif",true); } } System.out.print(ret); } catch(Exception e) { e.printStackTrace(); } } }