根據網絡上的一些資料以及個人使用的經驗,總結一些rtf域的特性供各位參考:
1、 使用rtf域在b/s上存儲內容突破域大小限制的問題。
很多時候,存儲超過64k的限制,在這個時候:
錯誤的代碼:
1、 使用rtf域在b/s上存儲內容突破域大小限制的問題。
很多時候,存儲超過64k的限制,在這個時候:
錯誤的代碼:
String s = “html 內容” ;
s += “….”;
s+= “……”;
doc.replaceItemValue(“ItemName”,s);
s += “….”;
s+= “……”;
doc.replaceItemValue(“ItemName”,s);
正確的代碼:
RichTextItem rtf = (RichTextItem) doc.getFirstItem(“ItemName”);
rtf.appendText(“html 內容”);
rtf.apendText(“………..”);
rtf.appendText(“html 內容”);
rtf.apendText(“………..”);
在domino中,如果內容超過限制,domino 會自動在文檔中生成多個同名域來存儲相關內容。
2、 使用rtf域顯示隨機生成的html代碼:
首先:要確定,超過64k的時候一定要使用第一點所表述的方法。
其次:如果在頁面上沒有正確的顯示html代碼所描述的界面,而是將html代碼顯示出來,解決方法如下:
A、 如果存在循環
首先:要確定,超過64k的時候一定要使用第一點所表述的方法。
其次:如果在頁面上沒有正確的顯示html代碼所描述的界面,而是將html代碼顯示出來,解決方法如下:
A、 如果存在循環
for(int i=0;i<n;i++)
{
rtf.apendText(“[”);
…………….
循環主體
…………….
rtf.apendText(“]”);
}
{
rtf.apendText(“[”);
…………….
循環主體
…………….
rtf.apendText(“]”);
}
B、 如果還未解決問題,可以使用如下代碼(未經實際驗證,後果自負)
Dim richStyle
As NotesRichTextStyle
Set richStyle = session.CreateRichTextStyle
Call cdoc.RemoveItem( "Body" )
Dim myrichText As New NotesRichTextItem(cdoc, "Body")
richStyle.PassThruHTML = True
Call myrichText.AppendStyle(richStyle)
Call myrichText.AppendText(getHtml)
As NotesRichTextStyle
Set richStyle = session.CreateRichTextStyle
Call cdoc.RemoveItem( "Body" )
Dim myrichText As New NotesRichTextItem(cdoc, "Body")
richStyle.PassThruHTML = True
Call myrichText.AppendStyle(richStyle)
Call myrichText.AppendText(getHtml)
說明:上面所講的內容包括使用lotusscript或者java。請自行根據所用語言進行相應轉換。
第二點的a方法要注意在取rtf域時的方法
if(doc.hasitem("ItemName"))
{
doc.removeItem("ItemName");
}
RichTextItem rtf = (RichTextItem) doc.getFirstItem("ItemName");
{
doc.removeItem("ItemName");
}
RichTextItem rtf = (RichTextItem) doc.getFirstItem("ItemName");