Difference between revisions of "Newsgroup summaries:mozilla-dev-embedding:2006-10-06"

From CDOT Wiki
Jump to: navigation, search
 
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Announcements=
+
=FAQ=
TBA
+
===How to customize document retrieval===
=Discussions=
+
One method is to implement your own protocol method. You can find more information on adding new protocols [http://kb.mozillazine.org/Dev_:_Protocol_Handlers here]
#[http://www.google.ca Handling the document retrival for an embedded gecko ] <br>
+
===How to embedding mozilla inside of Java===
Using your own method to retrieve documents rather than looking up the URL on the network.
+
There hasn't been any good code examples found. However, there is a stripped down, uncommented code with eclipse libraries in [http://groups.google.com/group/mozilla.dev.embedding/browse_thread/thread/46c259db088ee584/76f2073388eaffdd#76f2073388eaffdd this] thread. Here is the code :
#[http://www.google.ca Difficulty embedding mozilla using java] <br>
+
<pre>
Trying to find a good example of how to embed mozilla using Java.
+
import org.eclipse.swt.SWT;
=Meetings=
+
import org.eclipse.swt.browser.MozillaBrowser;
TBA
+
import org.eclipse.swt.browser.ProgressEvent;
 +
import org.eclipse.swt.browser.ProgressListener;
 +
import org.eclipse.swt.widgets.Display;
 +
import org.eclipse.swt.widgets.Shell;
 +
import org.mozilla.xpcom.nsIDOMDocument;
 +
 
 +
public class Test {
 +
        public static void main(String args[]) {
 +
                Display display = new Display();
 +
                Shell shell = new Shell(display);
 +
 
 +
                final MozillaBrowser browser = new MozillaBrowser(shell,WT.BORDER);
 +
                browser.setUrl("http://www.google.com");
 +
                browser.addProgressListener(new ProgressListener() {
 +
                        public void changed(ProgressEvent event) {
 +
                        }
 +
 
 +
                        public void completed(ProgressEvent event) {
 +
                            nsIDOMDocument doc = browser.getDocument();
 +
                                System.out.println(doc);
 +
                        }
 +
                });
 +
 
 +
                while (!shell.isDisposed()) {
 +
                        if (!display.readAndDispatch()) {
 +
                                display.sleep();
 +
                        }
 +
                }
 +
        }
 +
</pre>
 +
===How to map a javascript function to a C++ function===
 +
Define an XPCOM class  defining the function you'll be doing in javascript. Then pass the object to your XPCOM coded object and call it from C++. You can find this answered repeated and with an example  [http://groups.google.com/group/mozilla.dev.embedding/browse_thread/thread/af33a04e00387f5d/34d897200d736061#34d897200d736061  here]

Latest revision as of 16:00, 6 October 2006

FAQ

How to customize document retrieval

One method is to implement your own protocol method. You can find more information on adding new protocols here

How to embedding mozilla inside of Java

There hasn't been any good code examples found. However, there is a stripped down, uncommented code with eclipse libraries in this thread. Here is the code :

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.MozillaBrowser;
import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.browser.ProgressListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.mozilla.xpcom.nsIDOMDocument;

public class Test {
        public static void main(String args[]) {
                Display display = new Display();
                Shell shell = new Shell(display);

                final MozillaBrowser browser = new MozillaBrowser(shell,WT.BORDER);
                browser.setUrl("http://www.google.com");
                browser.addProgressListener(new ProgressListener() {
                        public void changed(ProgressEvent event) {
                        }

                        public void completed(ProgressEvent event) {
                            nsIDOMDocument doc = browser.getDocument();
                                System.out.println(doc);
                        }
                });

                while (!shell.isDisposed()) {
                        if (!display.readAndDispatch()) {
                                display.sleep();
                        }
                }
        }

How to map a javascript function to a C++ function

Define an XPCOM class defining the function you'll be doing in javascript. Then pass the object to your XPCOM coded object and call it from C++. You can find this answered repeated and with an example here