reusing JaxeApplet

Help
jbrekle
2012-04-28
2013-05-01
  • jbrekle
    jbrekle
    2012-04-28

    Hi,

    your software looks promising, however I encountered some problems. I want to setup the JaxeApplet as an editor for a CMS/Wiki.

    what do the parameters mean? for testing i replaced them with String constants
            cheminConfig = "../config/XHTML_config.xml";
            fichierAEditer = "file:../config/XHTML_config.xml";
            String sNouveau = "abc";
            cheminDictionnaire = "a";
            cheminPhonetique = "b";
            scriptEnregistrement = "c";
            nouveau = sNouveau != null && !"".equals(sNouveau) && "oui".equals(sNouveau);
            editing = false;

    I already found out that cheminConfig is the config file and fichierAEditer the file to display/edit.
    I dont understand why you work with paths there. i would like to pass the document directly as a string parameter.

    when i run the code, i get a
    java.lang.NullPointerException
    at jaxe.JaxeElement.creer(JaxeElement.java:109)
    at jaxe.JaxeDocument.creerEnfantDuDocument(JaxeDocument.java:473)
    at jaxe.JaxeDocument.setDOMDoc(JaxeDocument.java:427)
    at jaxe.JaxeDocument.lire(JaxeDocument.java:349)
    at jaxeapplet.JaxeAppletFrame.<init>(JaxeAppletFrame.java:108)
    at jaxeapplet.JaxeApplet.editerFichier(JaxeApplet.java:224)
    at jaxeapplet.JaxeApplet.start(JaxeApplet.java:107)
    at sun.applet.AppletPanel.run(AppletPanel.java:476)
    at java.lang.Thread.run(Thread.java:679)

    I also tried the suggested minimal example from http://jaxe.sourceforge.net/en/pages_jaxe-developer-guide/jaxe-within-another-app.html :
                     JFrame frame = new JFrame();
    JaxeDocument jaxeDoc = new JaxeDocument("config/XHTML_config.xml");
    JaxeTextPane jaxeTextPane = new JaxeTextPane(jaxeDoc, frame);
    frame.getContentPane().add(jaxeTextPane);
    URL xmlFileURL;
    try {
    xmlFileURL = new URL("http://dbpedia.hg.sourceforge.net/hgweb/dbpedia/extraction_framework/raw-file/1f3bea061b7d/wiktionary/config-en.xml");
    jaxeDoc.lire(xmlFileURL);
    } catch (MalformedURLException e) {
    e.printStackTrace();
    }
    when i start it, it says "keine Konfigurationsdatei gefunden für config" (in english "No configuration file found for config"). what does that mean?

    its really sad thats the code is written in french, making it almost impossible to understand it.

     
  • I have not created a real documentation about it yet. The parameters are explained in French in JaxeApplet.java. I will translate it into English here :


    - config : path to Jaxe's configuration file based on the HTML file
    - fichier : URL for the XML file
    - nouveau : "oui" if it's a new file, "non", if the file already exists
    - dictionnaire : path to the .dico file, relative to the HTML file (optional)
    - phonetique : path to the .phon file, relative to the HTML file (optional)
    - enregistrement : URL the content will be sent to with a POST query whenever the file is saved (relative to the HTML file), (mandatory if the fichier parameter is used)

    There are 2 ways to use the applet :
    - with the parameters fichier and enregistrement, without Javascript.
    In this case, the file will be read from the URL specified in fichier, and saved with the script given by the parameter enregistrement (POST request, parameters chemin (path) and contenu (contents)).
    - with Javascript by using the editer() method to define the XML, getEditing() regularly to wait for the end of the edition, and getTexte() to get the XML contents.


    If you want to send the XML as a String with Javascript, you can use the following code (it uses an HTML form to read or write the XML) :

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Test for an applet controlled with Javascript</title>
    <script type="text/javascript">
    function verif() {
        if (document.applets['jaxe'].getEditing())
            setTimeout('verif()', 500);
        else {
            texte = document.applets['jaxe'].getTexte();
            if (texte != null)
                document.formulaire.texte.value = texte;
        }
    }
    function editer() {
        document.formulaire.texte.readOnly = true;
        document.applets['jaxe'].editer(document.formulaire.texte.value);
        setTimeout('verif()', 500);
    }
    </script>
    </head>
    <body>
    <h1>Test for an applet controlled with Javascript</h1>
    <form name="formulaire" action="">
    <applet name="jaxe" archive="JaxeApplet.jar,config/" code="jaxeapplet.JaxeApplet" width="10" height="10">
    <param name="config" value="config/XHTML_config.xml">
    Java is not enabled in your web browser
    </applet>
    <input type="button" value="Edit with Jaxe" onclick="editer()">
    <br>
    <textarea name="texte" rows="20" cols="100">
    &lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;/html&gt;
    </textarea>
    </form>
    </body>
    </html>
    

    The example in the developer guide is for a Java application, not a Java applet.

    You can also see the applet in action in WebJaxe ( http://media4.obspm.fr/outils/webjaxe/en/ ). Since you give an example with HTML, I have to say that I don't think Jaxe is the best HTML editor. Jaxe is better to edit documents with a semantic structure and markup, later to be transformed automatically into HTML for the web (or a CMS shortcuts if you want to use a CMS with a syntax that is neither XML nor HTML).
    FYI, I once tried to integrate the Jaxe applet into the SPIP CMS. I stopped developing that when I worked on WebJaxe, but it might be of interest to you. It's in French, but if you don't know any French you could use a translator to get the idea : http://media4.obspm.fr/outils/jaxe-spip/index.html
    google translation : http://translate.google.fr/translate?sl=fr&tl=en&js=n&prev=_t&hl=fr&ie=UTF-8&layout=2&eotf=1&u=http%3A%2F%2Fmedia4.obspm.fr%2Foutils%2Fjaxe-spip%2Findex.html