0

new FileUpload-Dialog

asked 2007-05-22 15:44:31 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4324343

By: nobody1

Hello,
mybe you can make an example how to create an cutom File-Upload-Dialog i have tried it one day, but it won't work!
I will short explain what i've done:
I have a button in my window "rootWindow" and on Click i make a new Dialog:

<window title="File-Upload" id="fu" border="normal" width="440px"
closable="true"
xmlns:h="http://www.w3.org/1999/xhtml" xmlns:zk="http://www.zkoss.org/2005/zk"
use="org.zkoss.zul.impl.FileuploadDlg">

<grid height="103px" onCreate="exportlabel.value = fc.selectedItem.value">
<rows>
<row>
FileChooser:
<listbox id="fc" rows="1" mold="select"
zk:onSelect="exl.value=self.selectedItem.value">
<listitem selected="true" value="" label="Benutzerdefiniert" />
<listitem value='C:\URL1' label="URL1" />
<listitem value='C:\URL2' label="URL2" />
</listbox>
</row>
<row>
Destinationfile: <textbox id="exl" width="200"
onBlur='setURL(String.valueOf(exl.value))' />
</row>
<row>
Sourcefile: <iframe width="100%" height="43px" style="margin-left:-5px"
src="zk/fileupload.dsp?dtid=${self.desktop.id}&uuid=${fu.uuid}&ac
tion=${arg.action}&max=${arg.max}"/>
</row>
</rows>
</grid>
</window>

then i have modified the fileupload.dsp:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" %> <%@ taglib uri="/WEB-INF/tld/web/core.dsp.tld" prefix="c" %> <%@ taglib uri="/WEB-INF/tld/zk/core.dsp.tld" prefix="z" %> <html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Upload</title>
<link rel="stylesheet" type="text/css"
href="${c:encodeURL('~./zul/css/norm**.css.dsp')}"/>


<script type="text/javascript">
<!--
function submitUpload() {
var wndid = '${param.uuid}';
var img = parent.$e(wndid + '!img');
if (img) img.parentNode.removeChild(img);
parent.zkau.beginUpload(wndid);
}

function cancelUpload() {
parent.setTimeout("zk.focus(window); zkau.sendRemove('${param.uuid}');", 100); }

function init() {
var inp = document.getElementById("file");
if (inp) inp.focus();
}
// -->
</script>

</head>
<body onload="init()">
<form style="margin-bottum:1px"
action="${param.action}?dtid=${param.dtid}&uuid=${param.uuid}"
enctype="multipart/form-data" method="POST" onsubmit="submitUpload()">
<input type="file" id="file" name="file" size="38"/>
<input type="submit" value="${c:l('mesg:org.zkoss.zul.mesg.MZul:UPLOAD_SUBMIT')}"
onclick="parent.zk.progress()"/>
<input type="button" value="${c:l('mesg:org.zkoss.zul.mesg.MZul:UPLOAD_CANCEL')}"
onclick="cancelUpload()"/>
</form>

</body>
</html>

it works, but i need the value of exl in my zscript-Funktion.
I hope somebody understand what i mean and can help me with an easy example how i can access thje value

greats
nobody1

delete flag offensive retag edit

12 Replies

Sort by ยป oldest newest

answered 2007-05-23 01:45:05 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4325806

By: jumperchen

Hi,
I don't understand what you meant.
And I cannot find it where <zscript> is in you example.
Could you provide more info about your issue?

Thanks,
Jumper

link publish delete flag offensive edit

answered 2007-05-23 04:47:08 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4325935

By: nobody1

I try to upload a file with a custom Dialog.
There I've a FileChooser where you can choose standard files.
If you have no standard file you can write the sourcepath manually.
At least you can you the file to Upload. This all is in the window in the first response.

Now is my problem, that i have either a zk Textbox with typ = file and i only get the path from lokal pc, so it won't work. So i've thought you can choose the Fileupload from ZK-Framework it woks, but then my Problem is how i can get the Value of the Textbox with the sourcepath?!
I hope it is more understanable then the text from yesterday.

Thanks
nobody1


link publish delete flag offensive edit

answered 2007-05-23 07:42:07 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4326094

By: jumperchen

Try:

<zscript>
...
exl.value //<-- resolve 1
...
</zscript>

or

<script type="text/javascript">

function xxx(){
$e("${exl.uuid}").value //<-- resolve 2
}
</script>

Regards,
Jumper

link publish delete flag offensive edit

answered 2007-05-23 08:01:20 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4326128

By: zanyking


Hi,

Are you mean's how to get inputStream Object while using Upload component?

I'm not sure what the "localPfad" is.

Fileupload.get().getStreamData();

will Returns the raw data in InputStream, is that what you need?



link publish delete flag offensive edit

answered 2007-05-23 08:28:10 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4326164

By: nobody1

No,
thats my idea, i have this:
<h:input id="exportfile" type="file" size="38"/> there i can choose a file and if i click a button this Value i get in my <zscript /> in form of a string.
Then i have the Pfad of the file on Client.
Now i want send this file to the server.
It's possible?

thanks
nobdy1

link publish delete flag offensive edit

answered 2007-05-23 08:41:39 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4326180

By: nobody1

No,
nothing works!
i call my zk Funktion insertFile() by click the button, then the above things are visible!
This is my zkFkt. insertFile:
void insertFile(){

Fileupload.setTemplate("./zk/upload.zul");
Object media = Fileupload.get();

if (media != null){
InputStream is = media.getStreamData();
byte[] b = Files.readAll(is);
alert(exl.value);
}
}

he gets the media but not exl.value

Thanks
nobody1

link publish delete flag offensive edit

answered 2007-05-23 09:09:51 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4326208

By: jumperchen

Where is the example? Is it in the class file or in the same zul file?
Could you provide "enough" example about your question?

Thanks,
Jumper


link publish delete flag offensive edit

answered 2007-05-23 09:16:15 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4326220

By: nobody1

Ok,
i have rootWindow with a button which call onClick this FKT.:

void insertFile(){

Fileupload.setTemplate("./zk/upload.zul");
Object media = Fileupload.get();

if (media != null){
InputStream is = media.getStreamData(); byte[] b = Files.readAll(is); alert(exl.value); } }

The Templates call a new Window from Template that is this:
<window title="File-Upload" id="fu" border="normal" width="440px" closable="true"
xmlns:h="http://www.w3.org/1999/xhtml" xmlns:zk="http://www.zkoss.org/2005/zk"
use="org.zkoss.zul.impl.FileuploadDlg">

<grid height="103px" onCreate="exportlabel.value = fc.selectedItem.value"> <rows> <row>
FileChooser:
<listbox id="fc" rows="1" mold="select"
zk:onSelect="exl.value=self.selectedItem.value">
<listitem selected="true" value="" label="Benutzerdefiniert" /> <listitem value='C:\URL1' label="URL1" /> <listitem value='C:\URL2' label="URL2" /> </listbox> </row> <row>
Destinationfile: <textbox id="exl" width="200"
onBlur='setURL(String.valueOf(exl.value))' /> </row> <row>
Sourcefile: <iframe width="100%" height="43px" style="margin-left:-5px"
src="zk/fileupload.dsp?dtid=${self.desktop.id}&uuid=${fu.uuid}&action=${
arg.action}&max=${arg.max}"/>
</row>
</rows>
</grid>
</window>

This calls the fileUpload.dsp:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" %> <%@ taglib uri="/WEB-INF/tld/web/core.dsp.tld" prefix="c" %> <%@ taglib uri="/WEB-INF/tld/zk/core.dsp.tld" prefix="z" %> <html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Upload</title>
<link rel="stylesheet" type="text/css"
href="${c:encodeURL('~./zul/css/norm**.css.dsp')}"/>


<script type="text/javascript">
<!--
function submitUpload() {
var wndid = '${param.uuid}';
var img = parent.$e(wndid + '!img');
if (img) img.parentNode.removeChild(img); parent.zkau.beginUpload(wndid); }

function cancelUpload() {
parent.setTimeout("zk.focus(window); zkau.sendRemove('${param.uuid}');", 100); }

function init() {
var inp = document.getElementById("file"); if (inp) inp.focus(); } // --> </script>

</head>
<body onload="init()">
<form style="margin-bottum:1px"
action="${param.action}?dtid=${param.dtid}&uuid=${param.uuid}"
enctype="multipart/form-data" method="POST" onsubmit="submitUpload()"> <input type="file" id="file" name="file" size="38"/> <input type="submit" value="${c:l('mesg:org.zkoss.zul.mesg.MZul:UPLOAD_SUBMIT')}"
onclick="parent.zk.progress()"/>
<input type="button" value="${c:l('mesg:org.zkoss.zul.mesg.MZul:UPLOAD_CANCEL')}"
onclick="cancelUpload()"/>
</form>

</body>
</html>

Then i return to my Fkt. insertFile()
and there i need the information exl.

I hope this is example enough

Thanks
nobody1



link publish delete flag offensive edit

answered 2007-05-23 10:51:08 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4326338

By: jumperchen

You cannot use it directly.
Try to store component, which is you want to use it, by yourself manual.
When you want to get any component in fileupload template, those component already have detached on idspace structure.

For example,

In your upload.zul,

...
Destinationfile: <textbox id="exl" width="200"
onBlur='setURL(String.valueOf(exl.value))' /> ...
<zscript>
desktop.setAttribute("exl",exl);
</zscript>

In insertFile method,
//alert(exl.value);
desktop.getAttribute("exl");


Regards,
Jumper

link publish delete flag offensive edit

answered 2007-05-23 12:58:58 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4326521

By: nobody1

Thank you very much,
it run!!!!!!!!!!!!!!!!!!!!!!!!!!!

nobody1

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2007-05-22 15:44:31 +0800

Seen: 1,077 times

Last updated: Apr 27 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More