Xpages 从“扩展库”对话框保存文档时,某些值为空
使用8.5.3 UP1 从对话框保存文档时,某些字段未填充。如果我从xpage中保存文档,它可以很好地保存这些字段。下面是一个简单的例子来说明这个问题:Xpages 从“扩展库”对话框保存文档时,某些值为空,xpages,Xpages,使用8.5.3 UP1 从对话框保存文档时,某些字段未填充。如果我从xpage中保存文档,它可以很好地保存这些字段。下面是一个简单的例子来说明这个问题: <xp:link text="Save Document By Dialog" id="link21"> <xp:eventHandler event="onclick" submit="false"> <xp:this.script><![CDATA[XSP.
<xp:link text="Save Document By Dialog"
id="link21">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[XSP.openDialog("#{id:dialog1}");]]></xp:this.script>
</xp:eventHandler>
</xp:link>
<br/>
<xp:button value="Save By Button" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action>
<xp:saveDocument var="document1"></xp:saveDocument>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xe:dialog id="dialog1" title="Dialog">
<br />
<b>
<xp:text escape="true" id="computedField1">
<xp:this.value><![CDATA[#{javascript:"Save this document?"}]]></xp:this.value>
</xp:text>
</b>
<br />
<br />
<xp:button value="Yes" id="button7">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.script><![CDATA[XSP.closeDialog("#{id:dialog1}");]]></xp:this.script>
<xp:this.action>
<xp:saveDocument var="document1"></xp:saveDocument>
</xp:this.action></xp:eventHandler>
</xp:button>
<xp:button value="No" id="button8">
<xp:this.onclick><![CDATA[XSP.closeDialog("#{id:dialog1}");]]></xp:this.onclick>
</xp:button>
</xe:dialog>
<br/><br/>
<xp:inputText id="TitleTX" value="#{document1.TitleTX}"></xp:inputText>
<br/><br/>
<xp:inputRichText id="inputRichText1" value="#{document1.ProcessMapsRT}">
</xp:inputRichText>
与xe:dialog关联的DOJO进程将对话框移动到DOM中的另一个位置,这意味着它将失去对文档主要部分中数据源的跟踪。如果使用SSJS保存对话框而不是简单的操作,它可能会更好
我使用自定义控件中包含的对话框获得了最大的成功,其中数据源通过复合数据传入。这样,到数据的连接就不会丢失并且仍然有效,但是,在这些情况下,我仍然使用SSJS进行保存
/新手
更新:这可能是使用Steve Pridemore在注释9#42中描述的技术的时候(参见)
首先将一个新事件放在XPage中的数据源级别上
<xp:eventHandler
id="saveEventHandler"
submit="true"
save="true"
event="calledbyid"
refreshMode="complete">
</xp:eventHandler>
“应该”这样做。我还没有完全测试过它,但是NoteIn9中的示例确实有效
/新手确保在打开对话框之前将数据发布到服务器。我建议使用SSJS syntax-getComponent(“dialog1”)打开这样的对话框。show()您是否尝试过使用DataContext定义您的数据源?我相信dataContext是一个全局对象 更新:保存文档时,DataContext甚至dominoDocument数据源都起作用,但问题是没有保存值。因此,我使用了一个viewScope变量来存储这些值,这就成功了。我不确定这是否对你有帮助,但你看,这对我很有用:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:this.data>
<xp:dominoDocument var="newDoc" formName="frmContact"></xp:dominoDocument>
</xp:this.data>
<xp:inputText id="inputText1" value="#{viewScope.firstName}"></xp:inputText>
<xp:inputText id="inputText2" value="#{viewScope.lastName}"></xp:inputText>
<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="dialog1">
<xp:this.action><![CDATA[#{javascript:getComponent("dialog1").show();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xe:dialog id="dialog1">
<xp:button value="Label" id="button2">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:newDoc.replaceItemValue("fldFirstName", viewScope.firstName);
newDoc.replaceItemValue("fldLastName", viewScope.lastName);
newDoc.save();
getComponent("dialog1").hide();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</xe:dialog>
</xp:view>
希望这有帮助 谢谢你的回复。我试着用SSJS保存文档,但仍然不起作用。下面是更新的对话框按钮代码:
您是如何将数据源传递到自定义控件的?你有我可以试试的例子吗?谢谢你的建议。我尝试使用SSJS代码打开对话框,但似乎没有任何区别。未保存的字段有共同点吗?它们是什么类型的控件?您是通过代码设置它们的值,还是通过用户键入它们?我的具体问题是两个动态绑定的富文本控件和文本字段。如果我用xpage上的按钮保存它们,没问题。但是在对话框中,这些字段被忽略了。您能指定一些示例代码吗?这样我就可以确保正确执行了?谢谢,我试过使用viewScopes,虽然它实际上不适合我的情况,但它确实引导我走上了一条可行的道路。在打开对话框之前,我只是给服务器打了个电话,这确实解决了问题。我的链接是这样的:XSP.partialRefreshPost(“#{id:TitleTX},{onComplete:function(){XSP.openDialog(“#{id:dialog5},{}}”)谢谢你的帮助!
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:this.data>
<xp:dominoDocument var="newDoc" formName="frmContact"></xp:dominoDocument>
</xp:this.data>
<xp:inputText id="inputText1" value="#{viewScope.firstName}"></xp:inputText>
<xp:inputText id="inputText2" value="#{viewScope.lastName}"></xp:inputText>
<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="dialog1">
<xp:this.action><![CDATA[#{javascript:getComponent("dialog1").show();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xe:dialog id="dialog1">
<xp:button value="Label" id="button2">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:newDoc.replaceItemValue("fldFirstName", viewScope.firstName);
newDoc.replaceItemValue("fldLastName", viewScope.lastName);
newDoc.save();
getComponent("dialog1").hide();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</xe:dialog>
</xp:view>