xPages - 如何追加 &将文本添加到富文本字段 [英] xPages - how to append & prepend text to a richtext field

查看:28
本文介绍了xPages - 如何追加 &将文本添加到富文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将应用程序迁移到 xpages.我有一个由应用程序收到的电子邮件创建的文档.创建的文档上的富文本字段包含电子邮件正文.有人通过更新此字段并点击发送"按钮来响应发件人.在它真正消失之前,我在发送的内容前面加上一些文本.我尝试了很多方法来做到这一点,但被难住了.

I'm migrating an app to xpages. I have a doc that's created from an email received by the app. A richtext field on the created document contains the email body. Someone responds to the sender by updating this field and hitting the Send button. Before it actually goes out, I prepend and append a bit of text to the content being sent. I tried lots of ways to do this but am stumped.

我知道 .getItemValue 返回一个向量,但我想无论如何我都会试一试但返回 null.

I know .getItemValue returns a vector but I thought I'd give it a shot anyway but returns null.

var rtiIssueField = maildoc.createRichTextItem("body");
rtiIssueField.appendText("**IMPORTANT:blah  **");
rtiIssueField.appendText("\n<LWST>");
rtiIssueField.appendText("\n"+stEntryDoc.getItemValue("Issue"));
rtiIssueField.appendText("\n</LWST>")

有什么提示吗?谢谢克莱姆

Any hints? thanks clem

推荐答案

非常感谢您的输入.我快到了.. 只需要清理几件事情.但有了你的提示,我能够做我需要的.我只是想谢谢你并发布我想出的代码,以防其他人需要它.

Thanks so much for the input. I'm nearly there.. Just a couple of things to clean up. But with your hints I was able to do what I needed. I just thought I'd thank you and post the code that I came up with in case someone else needs it.

    var stream:NotesStream = session.createStream();
    //Grab the contents of the rt field on the web that has just been edited:
    var issueRT:NotesRichTextItem = getComponent("issue1").getValue();
    //Prefix some additional information for the customer.
    stream.writeText("**IMPORTANT: When responding, please do not include the history.  That is, remove this line and everything below it. **");
    //carriage return:
    stream.writeText("<p>");
    //Prefix a tag that will be used to strip off text if they respond WITH email history.
    stream.writeText("&lt;LWST&gt;");
    //carriage return:
    stream.writeText("<p>");
    //Prefix the 
    //Prefix a view scoped variable that contains things like date, responder, etc.
    stream.writeText(viewScope.ResponseHeader);
    //Add the contents of the rt field.
    stream.writeText( issueRT.getText() );
    //carriage return:
    stream.writeText("<p>");
    //Add the end tag.
    stream.writeText("&lt;/LWST&gt;");
    //Create the email body field.
    var emailBody:NotesMIMEEntity = maildoc.createMIMEEntity("body");
    emailBody.setContentFromText(stream,"text/html;charset=UTF-8", 1725);

    stream.close();

这篇关于xPages - 如何追加 &amp;将文本添加到富文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆