Thomas Oeding schrieb:
Hello Bjoern,

thank you for the examples. one more question, can i add
additional post parameters to the upload method?

i tried somethink like this:

        var formId = new QxTextField();
        formId.setHtmlProperty("name", "id");
var formFileName = new QxTextField();
        formFileName.setHtmlProperty("name", "filename");

but nothing works. for each QxTextField Qooxdoo make
internal a new Form field with a uniqe id and doesnt
attach it to the iframe upload form.

Sorry, file uploads are currently not implemented in qooxdoo. You must do it your own. There is currently no real form processing in qooxdoo available.

Sebastian



any ideas?

Greetings,
Thomas


After some work, I finally figured out a way to do it. There seem to
be others that have had the same question as me, so maybe this is
useful to someone. It is a little hackish because I couldn't find a
way to get input-tags with type "file" to layout correctly. If someone
knows a better way to upload files please tell me. Also I haven't
tested the method in any other browser than Firefox and Galeon but in
those it seem to work. Also qooxdoo doesn't have a form element so
it's not obvious how one should do it because you need a form element.

You need two parts, a QxTextField with type set to "file" and a
QxIframeTransport. When you want to upload the file you must clone the
input-tag in the QxTextField widget and attach it to
QxIframeTransport's _form element. Then you set the _form's enctype to
"multipart/form-data" and call setMethod("POST") on the
QxIframeTransport and submit the form. You can also add an handler
with addEventHandler to QxIframeTransport to know when the upload has
completed.

I have attached an example of it, which maybe can be added to qooxdoo?


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="de">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
  <title>Transport 7 @ qooxdoo :: demo</title>
  <link type="text/css" rel="stylesheet" href="../demolayout.css"/>
  <script type="text/javascript" src="../../script/qooxdoo.js"></script>
</head>
<body>
  <script type="text/javascript" src="../demolayout.js"></script>

  <div id="demoDescription">
    <p>Simple test for qooxdoo's transport implementation using some data for an 
addressbook.</p>
    <p>Using javascript/json content in this case.</p>
  </div>

  <script type="text/javascript">

  function QxUploadField(name)
  {
    QxTextField.call(this);
    this.setHtmlProperty("type", "file");
    this.setHtmlProperty("name", name || "upload");
  }
  QxUploadField.extend(QxTextField, "QxUploadField");

  function QxFileTransport()
  {
    QxIframeTransport.call(this);
    this.setMethod("POST");
    this._form.enctype = "multipart/form-data";
  };
  QxFileTransport.extend(QxIframeTransport, "QxFileTransport");

  QxFileTransport.prototype.setUploadWidget = function(widget)
  {
    var el = widget.getElement();
    this._form.appendChild(el.cloneNode(true));
  };

  window.application.main = function()
  {
    var d = this.getClientWindow().getClientDocument();

    var lay = new QxVerticalBoxLayout;
    lay.setLocation(20, 48);
    lay.setRight(335);
    lay.setBottom(48);
    this.add(lay);

    var fsq = new QxFieldSet("Request");
    fsq.setHeight("auto");
    lay.add(fsq);

    var hlay = new QxHorizontalBoxLayout;
    hlay.setVerticalChildrenAlign("middle");
    hlay.setSpacing(4);
    hlay.auto();
    fsq.add(hlay);

    upload = new QxUploadField();

    hlay.add(upload);

    button = new QxButton("Upload!");

    // Layouting doesn't seem to work with input type="upload"
    button.setLeft(110);
    hlay.add(button);

    button.addEventListener("execute", function(e) {
      var transport = new QxFileTransport();
// You need to have a webserver running with a page named
      // "upload" to actually upload the file.
      transport.setUrl("http://localhost:8080/upload";);
      transport.setUploadWidget(upload);
      transport.addEventListener("completed", function(e) {
        alert("File " + upload.getValue() + " was uploaded!");
      });
      transport.send();
    });
  }
</script>
</body>
</html>




---

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese  E-Mail
irrtümlich erhalten haben, informieren Sie bitte sofort den  Absender und
vernichten Sie diese Mail. Das unerlaubte Kopieren sowie  die unbefugte
Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail.  Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.

Ce message et toutes ses pièces jointes sont confidentiels et destinés à
l'usage exclusif du destinataire. La personne qui reçoit ce message et qui
n'est pas le destinataire est avisée que la lecture, transmission ou toute
autre utilisation de ce message est interdite et peut entraîner des
poursuites judiciaires à son encontre. Si vous avez reçu ce message par
erreur, merci de prendre contact avec l'expéditeur, par téléphone ou mail,
et de supprimer ce message et ses pièces jointes de votre système
informatique.


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to