You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Manuel

Administrator

  • "Manuel" is male
  • "Manuel" started this thread

Posts: 256

Date of registration: Jul 16th 2008

Location: Erlangen, Germany

Occupation: Software Developer

Hobbies: Jabaco, game theory, text-mining

  • Send private message

1

Friday, August 22nd 2008, 1:51am

Using Java-Framework's inside Jabaco

There are millions ;) of Frameworks based on Java. Jabaco is based on Java too - so it is very simple to use every Java-Library with Jabaco. You could use Frameworks like Hibernate, Java3D, eFace, ... Let's go.

I'll show you how to use the Java XML-Lib. I have googled for Java XML and found javax.xml.parsers.DocumentBuilderFactory. That sounds good and so i have a look to http://java.sun.com/j2se/1.4.2/docs/api/…derFactory.html

Ok, this Class is abstract and have a static method "newInstance()". This is a singleton pattern (don't know what that is? Have a look to http://en.wikipedia.org/wiki/Singleton_pattern). There are some syntax-differents from Java to Jabaco. For Jabaco you have to replace the "." to "#" in the namespace.

Jabaco Source

1
2
Dim tmpFactory As javax#xml#parsers#DocumentBuilderFactory = javax#xml#parsers#DocumentBuilderFactory.newInstance()
'Same in Java: javax.xml.parsers.DocumentBuilderFactory tmpFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();


Now we should have a new Instance of the document factory and could create a DocumentBuilder (http://java.sun.com/j2se/1.4.2/docs/api/…entBuilder.html). There is the next interesting method "parse()" which returns a instance that is compatible to the "org.w3c.dom.document"-interface (http://java.sun.com/j2se/1.4.2/docs/api/…m/Document.html). That's what we want:

Jabaco Source

1
2
3
Dim tmpFactory As javax#xml#parsers#DocumentBuilderFactory = javax#xml#parsers#DocumentBuilderFactory.newInstance()
   Dim tmpDocument As org#w3c#dom#Document 
   tmpDocument = tmpFactory.newDocumentBuilder().parse("c:\test.xml")


That's all you need to instance a Java-Class inside Jabaco. Now you can use it:

Jabaco Source

1
2
3
4
Dim tmpFactory As javax#xml#parsers#DocumentBuilderFactory = javax#xml#parsers#DocumentBuilderFactory.newInstance()
   Dim tmpDocument As org#w3c#dom#Document 
   tmpDocument = tmpFactory.newDocumentBuilder().parse("c:\test.xml")
   MsgBox tmpDocument.getDocumentElement().getTagName

Rate this thread
WoltLab Burning Board