I have an XPage that is not bound to a dataSource. The XPage contains two Custom Controls that are each bound to a different dataSource say mainDoc and transDoc. From an action button in transDoc I need to get a handle to the dataSource of the main custom control and the dataSource "mainDoc". This Action button needs to perform a save on mainDoc, plus some other stuff. I have some logic that 'hides' the mainDoc custom control and displays the transDoc control. The user then fills in some info in the transDoc Control and clicks an action that needs to then save the mainDoc first then save the transDoc. The sequence of the saves is crucial. Under some conditions we might hide the transDoc control and un-hide the mainDoc control without saving, I have that part working because I do not need to get the dataSource handle to do that.
I seem to vaguely remember reading something like this somewhere but can't seem to find it now.
An easy way to access the data source from another custom control is using a scope variable.
Set in first custom control a view scope variable to data source mainDoc
in beforePageLoad
event:
<xp:this.beforePageLoad>
<![CDATA[#{javascript:viewScope.sourceMainDoc = mainDoc}]]>
</xp:this.beforePageLoad>
Then you can work in second custom control with this view scope and e.g. save the mainDoc
:
<xp:this.action>
<![CDATA[#{javascript:viewScope.sourceMainDoc.save()}]]>
</xp:this.action>
Alternative
Use Sven Hasselbach's way to get data source from custom control. You'll get an object of instance com.ibm.xsp.model.domino.DominoDocumentData
. If you want to use same methods like for normal data source Domino Document objects (= NotesXspDocument) you have to get an object of instance com.ibm.xsp.model.domino.wrapped.DominoDocument
with getDataObject()
first. You can do it this way:
function getDatasource( componentId:String, dataSourceName:String ):com.ibm.xsp.model.domino.DominoDocumentData {
...
}
var mainDoc:com.ibm.xsp.model.domino.wrapped.DominoDocument = getDatasource("idDSComponent", "mainDoc").getDataObject();
mainDoc.save()
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다