ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

more fileupload customizations

admin
9 Oct 2007 23:14:30 GMT
9 Oct 2007 23:14:30 GMT


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

By: hlezmana

hi,

Wondering if anyone can help me customizing fileupload so that the upload button says "Some text" rather than "Upload". In addition, I need the fileupload dialog window to accept only excel files.

I am trying to create a window that takes 2 excel files, then perform some calculation on the 2 excel files which then produces another excel file (in the form of file download). So essentially speaking combining the fileupload component and filedownload component to one single button. Is that doable?

Is it possible to mimic the Fileupload component using a regular button and a couple <input> elements? I was looking at the UploadEvent but couldn't figure out how i could fire that off manually. In addition i don't know how to construct the underlying media object from a filepath.

Any suggestion?

Thanks,
Akin





admin
10 Oct 2007 07:49:53 GMT
10 Oct 2007 07:49:53 GMT


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

By: jebberwocky

Dear Akin

To contruct a media object from a filepath:

java.io.InputStream is = desktop.getWebApp().getResourceAsStream("/me.pdf");
Media = new AMedia(FILE_NAME, null, "application/pdf", is)

for the AMedia's constructor, please refer to zcommons javadoc http://www.zkoss.org/javadoc/3.0.0-RC/zcommon/

//Jeff

admin
10 Oct 2007 09:40:28 GMT
10 Oct 2007 09:40:28 GMT


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

By: sousa1981

"Wondering if anyone can help me customizing fileupload so that the upload button says "Some text" rather than "Upload". In addition, I need the fileupload dialog window to accept only excel files."

Try:
Fileupload fu = new Fileupload();
fu.setTemplate("/zul/fileupload.zul");
Media[] aux_ficheiros = fu.get("only excel", "my App", MAX_FILEUPLOAD_SIZE); if (aux_ficheiros != null) {
for (int i = 0; i < aux_ficheiros.length; ++i) {
if (isAllowed_extensions(getExtension(aux_ficheiros[i].getName())) {
// Process File
}
}
}

Where "/zul/fileupload.zul" is an template that you copied from ZK Src file and modified the test "Upload" to "Some text" and that template is in your WebRoot "/zul/fileupload.zul"

Hope this help,

Marcos de Sousa

admin
10 Oct 2007 14:50:22 GMT
10 Oct 2007 14:50:22 GMT


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

By: hlezmana

Thanks so much, i'll try those.

I am still having trouble looking up the template file "/zul/fileupload.zul".
I browsed most of the folders in SVN. Couldn't find a file named fileupload.zul.

Akin

admin
10 Oct 2007 15:14:50 GMT
10 Oct 2007 15:14:50 GMT


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

By: sousa1981

On the SRC "zk-src-3.0.0-FL-2007-09-28"

Go to:\zk-src-3.0.0-FL-2007-09-28\zul\src\archive\web\zul\html

There is an fileuploaddlg.zul or something related.

Remember that the modification of fileupload will not working if u change version of zk.
To work, u must update the template according the version of zk (go to src and get the template version).

I use the fileupload.zul template, because I wanted to customize the template in size, height on version 2.4.1, in version 3, maybe it had been corrected, and I haven't an fileupload on version 3 in production.

Regards,

Marcos de Sousa




admin
10 Oct 2007 15:17:35 GMT
10 Oct 2007 15:17:35 GMT


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

By: sousa1981

You will have success, if you in addition, read the documentation (see the javadoc and pdf) about upload and download.

Because my information maybe be incorrect.

Regards,

Marcos de Sousa


admin
10 Oct 2007 16:23:26 GMT
10 Oct 2007 16:23:26 GMT


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

By: hlezmana

Thanks again Marcos,

the fileuploaddlg.zul uses fileuploaddlg.dsp.

the following line seems to be the line that i need to change in fileuploaddlg.dsp:
<input type="submit" value="${c:l('mesg:org.zkoss.zul.mesg.MZul:UPLOAD_SUBMIT')}"
onclick="parent.zk.progress()"/>

Is there any tutorial on modifying/building/deploying/maintaining such DSP file?

Akin

admin
11 Oct 2007 07:05:46 GMT
11 Oct 2007 07:05:46 GMT


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

By: sousa1981

You dont need to modify the DSP file, read the documentation how to customize the fileupload.

Regards,

Marcos de Sousa

by020827
8 Feb 2010 22:52:40 GMT
8 Feb 2010 22:52:40 GMT

dear all:
I have a question.
how to get "ture file" into my customize's folder space.

ex:
client upload a file [name=hello.xls] into this folder↓
C:\upload

how can i get file in C:\upload
if use Reader , i got Error message : use getByteData() instead .

please help me

iantsai
11 Feb 2010 19:49:13 GMT
11 Feb 2010 19:49:13 GMT

uh... first I'm not sure if this problem is a ZK problem.
But anyway, it's no really a big deal, the real problem is: Second, this is a very old post which seems has no relation to your problem, you should shoot a new post.

by020827
13 Feb 2010 00:35:19 GMT
13 Feb 2010 00:35:19 GMT

ok...thank you

giga
15 Mar 2010 06:59:39 GMT
15 Mar 2010 06:59:39 GMT

Marcos de Sousa mentioned documentation about how to customize the fileupload. Where can I find this?
Basically I want to change the name of the submit button and not showing the cancel button. I am using the fileupload component built in the page and not like pop up.


Thanks for anyone´s help

PeterKuo
15 Mar 2010 20:37:16 GMT
15 Mar 2010 20:37:16 GMT

@giga,
you may refer to
http://docs.zkoss.org/wiki/ZK_5:_New_File_Upload

It's latest feature since zk5.

giga
16 Mar 2010 06:25:15 GMT
16 Mar 2010 06:25:15 GMT

Thanks for the answer PeterKuo!
I knew about the new file upload but for now I´m still using ZK 3.6.3 so that new feature is still not available for me, must use the old fileupload fellow.

iantsai
17 Mar 2010 04:19:15 GMT
17 Mar 2010 04:19:15 GMT

you can call: Fileupload.setTemplate(url), which will change ZK Fileupload's template to destination zul file.

giga
17 Mar 2010 05:25:48 GMT
17 Mar 2010 05:25:48 GMT

I know but for what I read that methods only work with modal fileupload dialog and I´m using the component itself built in the page.
Anybody know how I can work with the cancel button? Which event I can grab besides the onClose event that is the same event for both buttons?

iantsai
17 Mar 2010 20:26:53 GMT
17 Mar 2010 20:26:53 GMT

maybe you can past a piece of sample code, and we can find a workaround for you.

giga
18 Mar 2010 06:48:12 GMT
18 Mar 2010 06:48:12 GMT

OK, in my zul I have this:

<groupbox style="background-color:white" >
<caption label="Assinatura digitalizada" />
<grid fixedLayout="true" style="border:none;" >
<columns>
<column width="250px" />
<column />
</columns>
<rows>
<row style="background-color:white;border:none" >
<fileupload use="" id="fileupload" height="60px" onUpload="winGestaoAssinaturas.onUploadAssinatura(event)" />
<image id="assDigitalizada" content="@{winGestaoAssinaturas.assDigitalizada, load-when='responsavelDocListbox.onSelect', load-after='searchButton.onClick, fileupload.onUpload, guardar.onClick, limpar.onClick'}" height="100px" width="100%" />
</row>
</rows>
</grid>
</groupbox>


My java code:

public void onUploadAssinatura(UploadEvent event) {
try {
Media ficheiro = event.getMedia();
if (ficheiro != null) {
if (ficheiro instanceof org.zkoss.image.Image) {
setAssDigitalizada(ImageIO.read(ficheiro.getStreamData()));
getResponsavelDocSelected().getScpResponsavelDoc().setFicheiro(ficheiro.getByteData());
}
else {
setAssDigitalizada(null);
Messagebox.show("Não é um ficheiro de imagem: " + ficheiro, "Erro", Messagebox.OK, Messagebox.ERROR);
}
}
else {
Messagebox.show("Não foi carregado nenhum ficheiro de imagem.", "Informação", Messagebox.OK, Messagebox.INFORMATION);
}
} catch (InterruptedException e) {
log.debug("InterruptedException", e);
} catch (IOException e) {
log.debug("IOException", e);
}
}

The code shown is only relevant to the fileupload component.
Thanks for the feedback until now.

iantsai
18 Mar 2010 23:58:12 GMT
18 Mar 2010 23:58:12 GMT

Finally I got your point.

You have a button which will trigger file upload, after clicking, it will popup a dialog asking you the destination file's OS directly, and you want to disable the Cancel button in this dialog.

unfortunately, the dialog you saw is a Browser native dialog which is been designed to support native HTML file upload, it's uncangable and ZK use it as default implementation.
To fulfill this requirement, you need to use other technology like Java Applet, Adobe Flash or MS Silver Light to customize a Client side app hooked in browser.

I think you can ask zk for customization service.

giga
19 Mar 2010 08:25:53 GMT
19 Mar 2010 08:25:53 GMT

Thanks for the answer, sorry for not being totally clear in what I wanted.
Maybe I´ll migrate to ZK 5.0.1 EE so with new upload component I can do more what I want.
Take care

1 2