Create a uniqe document (no dupes)

Hi folks,

I am using as an example the Telephone Schema and the generated application from that Schema. Now I want to create new entries, but I want to ensure that only documents with a different LoginName and Password can be stored. In case of dupes, a appropriate page should be displayed.

I wont get any hints reading the documentation. Any ideas ?


X-Application Version: 3.1.2
Tamino Version : 3.1.1
Platform : Win2k
WebContainer : Tomcat 3.3
JDK Version : 1.3.1


with the next version 3.1.3 of X-Application you can add plugin which makes this check. For example

<BR>	public static void validateEntry(BusinessDocument newDoc, BusinessDocumentWorkspace ws) <BR>		throws XException<BR>	{<BR>		String logon = newDoc.selectElement("/telphone.../loginName").getText();<BR>		String password = newDoc.selectElement("/telphone.../password").getText();<BR>    	String checkQuery = "/telephone[.../logon='" + logon + "'" + " and .../password='" + password + "']";<BR>		<BR>		if (ws.getStore().count(checkQuery) == 0) {<BR>			newDoc.commit();<BR>		} else {<BR>			throw new XException("TEL001", new String[]{logon, password});<BR>		}<BR>	}<BR></pre><BR><BR>However, I don't know the telephone schema. But your mail sounds as logon and password are part of the document you want to commit.<BR><BR>For the current version 3.1.2 of X-Application you could add this check by a Scriptlet.<BR><BR><pre class="ip-ubbcode-code-pre"><BR><%<BR>    	SessionContext sessionContext = ServletSessionContext.getSessionContext(pageContext);<BR>		BusinessDocumentWorkspace ws = sessionContext.getWorkspace();<BR>		BusinessDocument doc = ws.lookup("name of your document");<BR>		String password = doc.getDescendant("path expression").getValue();<BR>		String logon = doc.getDescendant("path expression").getValue();<BR>		String checkQuery = ...;<BR>		if (ws.getStore().count(checkQuery) == 0) {<BR>			doc.commit()<BR>		} else {<BR>			out.print("an error message");<BR>		}<BR>%><BR>

Remark: you have to import the required classes (e.g. ServletSessionContext, SessionContext, BusinessDocumentWorkspace).

Hope, that aswers you question.


[This message was edited by Christian Freytag on 18 Jul 2002 at 12:22.]