xpages passing the UNID to other field

2019-09-03 15:25发布

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.

标签: xpages
2条回答
贪生不怕死
2楼-- · 2019-09-03 15:55

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.

查看更多
对你真心纯属浪费
3楼-- · 2019-09-03 16:02

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.

查看更多
登录 后发表回答