How to retrieve the document id?

I have created a document and committed successfully into the tamino server using tamino jsp tagging.

How do i retrieve the document “id” that i just
created using tamino jsp tags.

I also need to associated this “id” to a jsp variable… as i need to do some processing.

I tried using…

TaminoStore store = new TaminoStore(“http://localhost/tamino/myDB");<BR>store.registerDoctypeCollection("Property”, “myCollection”);
BusinessDocumentWorkspace ws = new BusinessDocumentWorkspace(store);

BusinessDocument doc = ws.lookup(“myCollection”);
String id = doc.getId();

however, i find that doc is null.



X-Application Version: 3.1.2, 3.1.1
Tamino Version : 3.1.1
Platform : NT, Win2k, Solaris, …
WebContainer : Tomcat 3.3
JDK Version : 1.3.1

I’ve done it like this, but if there are other ways I would be interested…

<%@ page import=“com.softwareag.xtools.xapplication.businessdocument." %>
<%@ page import="com.softwareag.xtools.xapplication.jsp.
” %>

<%@ page import=“java.util.StringTokenizer” %>



// First, get a session context…
SessionContext mySessionContext = ServletSessionContext.getSessionContext(request.getSession());

// …then get the id of the document just created…
String myInoId = mySessionContext.getDocumentId(“current”);
// … getDocumentId returns “/doctype[@ino:id=‘nnn’]” so we have to extract the number…
StringTokenizer st = new StringTokenizer(myInoId,“'”);
String temp = st.nextToken(); // prefix of ino:id
String inoId = st.nextToken(); // the ino:id itself.

//… and maybe access some xml elements of the current document…
BusinessDocument doc = mySessionContext.getDocument(“current”);
…doc.getDescendant(“/rootnode/elementnode”).getValue()…

HTH
X-Application Version: 3.1.2, 3.1.1
Tamino Version : 3.1.1
Platform : NT, Win2k, Solaris, …
WebContainer : Tomcat 3.3
JDK Version : 1.3.1

[This message was edited by Bill Leeney on 04 Jul 2002 at 09:50.]

Hello,

when you used the JSPs and tag library of X-Application to create a new document (e.g.
<bdm:action type=“create” schema=“Property”>…</bdm:action> ), the new document is created within the workspace. It has no ino:id. It gets its id if it is committed.

<bdm:action type=“commit” >…</bdm:action>

If you want to display the ino:id after committing the document, you can use

<bdm:display select=“$ID”/>

If you want to access the document via scriptlet

<BR>    SessionContext sessionContext = ServletSessionContext.getSessionContext(pageContext);<BR>    BusinessDocumentWorkspace ws = sessionContext.getWorkspace();<BR>    BusinessDocument doc = ws.lookup("current");<BR>    String id = doc.getId();<BR>



Remark: If you define the attribute ‘document’ for your create action, the new document is registered by this name within workspace.

<bdm:action type=“create” schema=“Property” document=“myDoc”>…

You have to use this name, when committig the document

<bdm:action type=“create” document=“myDoc”>…

and when looking up this document

… ws.lookup(“myDoc”);

The name “current” is used by default if no attribute is set.

Does this information help you?

Bye,
Christian.

Yes, I should have said that my code to access the ino:id is in the view page, not the create page.

It is only executed if I get to the view page directly after a committed create.