HI,
I have already discussed here but did not find what I was looking for
(http://groups.google.com/group/google-web-toolkit/browse_thread/
thread/e7a880a22a129bfa?hl=en).

For my web application I use GWT 2.1.0 with Eclipse 1.3.8 and App
Engine.
I would like to write the values obtained as a parameter (from the
TextBox) in an XML file.
I know that is not possible to write client-side file. But I think you
can do in server-side.

I set the RPC call (see the tutorial).
I can not use the java.io.File class to write (because G App Engine
does not provide for this class, I saw here:
http://code.google.com/intl/it-IT/appengine/docs/java/jrewhitelist .
html).

But I can use classes to write to files as Transform and DOMSource ..

This is my code in Server-side:

package de.vogella.gwt.helloworld.server;

import java.io.*;
import org.w3c.dom.*;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import de.vogella.gwt.helloworld.client.MyService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;


public class MyServiceImpl extends RemoteServiceServlet implements
MyService {

        /*
        //implementazione del metodo funzionante
         public String testRPC(String message)
                {
                        Date now = new Date();
                        String dtm =
DateFormat.getTimeInstance(DateFormat.MEDIUM).format(now);


                        return "Ecco il messaggio inviato '" + message +"' 
quando sono
precisamente le : " + dtm;
                }
   */

        //metodo che inserisce il nuovo iscritto
        public void creaXML(String nickname,String pass,String email2,String
gio,String mes, String ann){

                /*
                 XML format (keywords are space delimited):
       <utenti> <--giĆ  presente
          <utente>
             <nick>...</nick>
             <psw>...</psw>
             <mail>...</mail>
             <datan>
                        <gg>...</gg>
                        <mm>...</mm>
                        <aa>...</aa>
                  </datan>
          </utente>
      </utenti>
                */

                String dest = "utenti.xml";
                Document doc = null;
                DocumentBuilder db = null;
                //Istanziazione di DocumentBuilderFactory
                DocumentBuilderFactory dbf = 
DocumentBuilderFactory.newInstance();
                //Istanziazione di DocumentBuilder
                try{
                        db = dbf.newDocumentBuilder();
                }
                catch(ParserConfigurationException pce){
                        System.err.println("Errore per DocumentBuilder");
                }

                        try {
                                doc = db.parse("utenti.xml");
                        } catch (SAXException se) {
                                // TODO Auto-generated catch block

                        } catch (IOException ioe){
                                System.err.println(ioe);
                        }
                        Node root = doc.getDocumentElement(); //root=<utenti>

                        Node utente = doc.createElement("utente");
                        root.appendChild(utente);

                        Node nick = doc.createElement("nick");
                        Node Tnick = doc.createTextNode(nickname);
                        nick.appendChild(Tnick);
                        utente.appendChild(nick);

                        Node password = doc.createElement("psw");
                        Node Tpass = doc.createTextNode(pass);
                        password.appendChild(Tpass);
                        utente.appendChild(password);

                        Node email = doc.createElement("mail");
                        Node Tmail = doc.createTextNode(email2);
                        email.appendChild(Tmail);
                        utente.appendChild(email);

                        Node datan = doc.createElement("datan");
                        utente.appendChild(datan);

                        Node giorni = doc.createElement("gg");
                        Node Tgg = doc.createTextNode(gio);
                        giorni.appendChild(Tgg);
                        datan.appendChild(giorni);

                        Node mesi = doc.createElement("mm");
                        Node Tmm = doc.createTextNode(mes);
                        mesi.appendChild(Tmm);
                        datan.appendChild(mesi);

                        Node anni = doc.createElement("aa");
                        Node Taa = doc.createTextNode(ann);
                        anni.appendChild(Taa);
                        datan.appendChild(anni);
                        System.out.println("ci sono");
                        try{
                        DOMSource sorgente = new DOMSource (doc);
                        StreamResult sr = new StreamResult (dest);
                TransformerFactory tf =
                    TransformerFactory.newInstance();
                Transformer transf = tf.newTransformer();
                transf.transform(sorgente,sr);
                        }
                        catch (TransformerConfigurationException tce)
                     {
                        System.out.println(tce.getMessage());
                     }
                     catch (TransformerException te)
                     {
                        System.out.println(te.getMessage());
                     }

        }

}

If I start the application I have this error:

javax.servlet.ServletContext log: Exception while dispatching incoming
RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method
'Public abstract void
de.vogella.gwt.helloworld.client.MyService.creaXML (java.lang.String,
java.lang.String, java.lang. String, java.lang.String,
java.lang.String, java.lang.String) 'Threw an unexpected exception:
javax.xml.transform.TransformerFactoryConfigurationError: Provider not
found org.apache.xalan.processor.TransformerFactoryImpl
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure
(RPC.java: 378) ...

Can anyone tell me if I'm doing the right thing? What error?

Thank you all for further clarification

Regards

Sebe

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to