是否从富文本控件设置具有replaceItemValue的文档字段? [英] Setting a document field with replaceItemValue from a rich text control?

查看:11
本文介绍了是否从富文本控件设置具有replaceItemValue的文档字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用丰富的tect控件中的replaceItemValue设置richText值?

我在这里找到了这段代码: http://www.bleedyellow.com/blogs/martin/entry/save_a_richtext_field_from_a_xpage_to_a_document?lang=en_us

var doc = configuratieformulieren.getDocumentByKey("ConfiguratieIVNL", true);
if(doc == null){
    return;
}else{    
    var titel = getComponent("inputTextIBPTitelIVNL").getValue();
    doc.replaceItemValue("IBPTitel",titel);    
   var inhoud = getComponent("inputRichTextIBPInhoudIVNL").getValue();
   if (inhoud != null){ 
   var contentType = doc.getMIMEEntity("IBPInhoud").getContentType();
   var encoding = doc.getMIMEEntity("IBPInhoud").getEncoding();
   var str = session.createStream();
   inhoud.toString();
   str.writeText(inhoud.toString());
   doc.getMIMEEntity("IBPInhoud").setContentFromText(str, contentType, encoding);    
 }

 doc.save(true, true);
}
sessionScope.put("FormulierIVNLInfoBeschPG","Lezen");

对吗?看起来这段代码取决于字段已经存在这一事实。如果字段不存在,如何处理此问题?是否有更简单的方法将字段值设置为格式文本控件的内容?

推荐答案

我能够解决我最初的问题。为了详细说明我的问题,我在使用对话框从表单/文档A使用表单A上的对话框创建表单/文档B时遇到了问题。发生的情况是,对表单B所做的任何更改都将保存到文档A的数据源。

我在窗体B的数据源上找到了ingoreRequestParams,并对其进行了设置,从而解决了窗体B写入窗体A文档的问题。

这篇关于是否从富文本控件设置具有replaceItemValue的文档字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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