the DemoInsert example compiles and runs ok, but how to handle tamino Exception with applet?
where is the error in the code below?
import com.softwareag.tamino.API.dom.;
import com.docuverse.dom.;
import java.applet.Applet;
import java.io.*;
public class Just4Test extends Applet
{
public void start()
{
try
{
TaminoClient tamino=new TaminoClient(“http://localhost/tamino/…”);
tamino.startSession();
BasicDocument doc=new BasicDocument();
BasicElement Element1 = new BasicElement(doc,“Element1”);
BasicElement Element2 = new BasicElement(doc,“Element2”);
Element2.appendChild(new BasicText(doc,“SubElement2”));
Element1.appendChild(Element2);
TaminoResult tr= tamino.insert(Element1);
tamino.commit(false);
tamino.endSession();
}
catch (com.softwareag.tamino.API.dom.TaminoError e)
{
System.out.println(…);
}
catch (IOException e)
{
System.out.println(…);
}
}
}
compiling Process ok, Applet doesn’t work.
thanks
Hi Lorenzo,
could you perhaps give us a hint about how the code doesn’t work please?
My three guesses are:
1) Maybe the URL you are using is incorrect.
new TaminoClient(“http://localhost/tamino/…”)
I assume that you are using some real value (not “…”), but it would help if we could see it!
2) You are inserting the root element, not the document that you created. Is that your intent?
tamino.insert(Element1)
3) Is there a schema defined to receive the document?
Cheers,
Trevor.
The other thing which may not be relevent in your case is that I thought Applets ran within a sandbox environment and that you couldn’t (by default) access the file system or other network URL’s other than the one where the applet came from.
First of all really thanks for the answers.
@Trevor Ford
1- TaminoClient tamino=new TaminoClient(“http://localhost/tamino/DatiIdrologici/Collection_FiumiFinale”);
and System.out.println(“Tamino Error Text: " + e.errorText );
of course.
2-i just follow the DemoInsert example.
3-of course. I’m sure about my data, the problem is elsewhere.
@Stuart Fyffe-Collins
if so, there is no way to use “applet & tamino”? I hope no.
In other words all i need is how to traslate in applet the following:
DemoInsert class under …/Software AG/Tamino/Tamino 3.1.1.4/Help/javaapi/samples
-----------------------------------------------
import com.softwareag.tamino.API.dom.;
import com.docuverse.dom.;
/* This Demo insert an xml document like this below:
Wehlmann124
/
public class DemoInsert {
public static final void main(String[] arg) throws Exception {
try{
TaminoClient tamino=new TaminoClient( parseArgs(arg) );
tamino.startSession();
BasicDocument doc=new BasicDocument();
BasicElement telephone = new BasicElement(doc,“Telephone”);
telephone.setAttribute(“EntryID”,“124”);
BasicElement c = new BasicElement(doc,“LoginName”);
c.appendChild(new BasicText(doc,“Wehlmann125”));
telephone.appendChild(c);
TaminoResult tr= tamino.insert(telephone);
tamino.commit(false);
tamino.endSession();
}
catch (com.softwareag.tamino.API.dom.TaminoError e){
System.out.println("Tamino Error Text: " + e.errorText );
System.out.println("Tamino Error Code: " + e.responseCode );
}
}
/ Definition of method parseArgs */
public static final String parseArgs(String args){
if (args.length >= 1)
return args[0];
else {
System.out.println(”\n>> Tamino Demo Programs << \n" +
“Copyright (c) 2000 SOFTWARE AG, ALL Rights Reserved. \n\n” +
“Usage: java Demo… database-url \n” +
" e.g.Tamino Version 1.2 java DemoQuery http://pcmypc/tamino/mydb \n" +
" e.g.Tamino Version 2.1 java DemoQuery http://pcmypc/tamino/mydb/mycollection \n" );
System.exit(0);
return null;
}
}
}
---------------------------------------
thanks.
Hello Lorenzo.
Good news: your code works fine for me! So I suspect that the problem is somewhere in the environment that you are using to execute the Applet.
Using this very simple HTML document in conjunction with the appletviewer.exe program I was able to insert the Telephone instance:
<HTML>
<BODY>
<APPLET CODEBASE="http://localhost/Applet" CODE="Just4Test.class" WIDTH=200 HEIGHT=300></APPLET>
</BODY>
</HTML>
</pre><BR><BR>I strongly recommend you to use the appletviewer program, as this will print any exceptions to the console. You might find that you have some of the necessary classes missing from your Applet's codebase.<BR>(I extracted the classes from taminoclient.jar, domsdk.jar, sax.jar, w3cdom1.jar and xp.jar into the Applet directory on my webserver.)<BR><BR>Here is the exact code that I used for the Applet:<BR><pre class="ip-ubbcode-code-pre">
import com.softwareag.tamino.api.dom.*;
import com.docuverse.dom.*;
import java.applet.Applet;
import java.io.*;
public class Just4Test extends Applet {
public void start() {
try {
TaminoClient tamino=new TaminoClient("http://localhost/tamino/test/xmldb");
tamino.startSession();
BasicDocument doc=new BasicDocument();
BasicElement telephone = new BasicElement(doc,"Telephone");
telephone.setAttribute("EntryID","124");
BasicElement c = new BasicElement(doc,"LoginName");
c.appendChild(new BasicText(doc,"Wehlmann125"));
telephone.appendChild(c);
TaminoResult tr= tamino.insert(telephone);
tamino.commit(false);
tamino.endSession();
} catch (com.softwareag.tamino.api.dom.TaminoError e) {
System.out.println(e.getMessage());
e.printStackTrace();
} catch (IOException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
I tried it with the appletviewer from JDK 1.3.1_04 and JDK 1.4.1
I hope that helps,
Trevor.
That help and resolve.
Really thank you.
Taminoclient and all the others jar was in classpath (this is the reason why java version runs i think) but this is not enought for applets.
Thanks to you, now is all clear.
Kind regards.