xpages passing the UNID to other field

青春壹個敷衍的年華 提交于 2019-12-12 04:54:42

问题


I have an input field:

   <xp:inputText value="#{Cdoc.txt_UNID}" id="txt_UNID1"></xp:inputText>

The field txt_UNID is computed having the value: @Text(@DocumentUniqueID).

What I noticed is that even I just compose the xpage containing the document content the inputText already contains some UNID even if the xpage containing the doc content wasn't saved.

There is a button which is showing a dialog containing a field. I want this field to have the value of txt_UNID

Cdoc.save(); // I must save first the Cdoc datasource ?
getComponent('exampleDialog').show()

And the code for the field:

<xp:inputText value="#{Pdoc.txt_CompanieUNID}"
id="txt_CompanieUNID1" defaultValue="#{Cdoc.txt_UNID}">
</xp:inputText>

Thanks for your time.


回答1:


If your question is whether or not you must first save the document in order to get the UNID, my answer is yes. In my tests, the UNID has changed from a new document to a freshly saved document. So, yes if the current document is new, save before getting the UNID. At least when it was a NotesXspDocument.

I also generally use JavaScript for this,

cdoc.getDocument().getUniversalId();

Otherwise, I am unsure what you are asking.




回答2:


If PDoc is available at the same level of the hierarchy as CDoc, e.g. both are datasources assigned to the XPage / Custom Control or the same Panel, you could update PDoc on save, using PDoc.replaceItemValue("txt_CompanieUNID",Cdoc.getDocument().getUniversalID()). setValue should also work. Then you would not need the default value.

It just helps keep all business logic in one place. You could also check whether a value has already been set.



来源:https://stackoverflow.com/questions/24302109/xpages-passing-the-unid-to-other-field

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!