0

How do you invoke file chooser dialog

asked 2007-02-20 22:35:22 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


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

By: lubosp

I don't want to upload any file but want only the file chooser dialog to be invoked, just like the browse button functionality in the Fileupload dialog.
I am writing my own dialogs that need to browse local files.

delete flag offensive retag edit

11 Replies

Sort by ยป oldest newest

answered 2007-02-21 10:39:52 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


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

By: henrichen

That is implemented with HTML tag

<input type="file">


/henri

link publish delete flag offensive edit

answered 2007-02-21 21:03:41 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


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

By: lubosp

Thanks Henri,

but how do I call it from onClick event handler (of the Browse... button), and how do I get the result from the <input type="file"> dialog?
I tried:

<attribute name="onClick">
<h:input type="file"/>
</attribute>

but obviously that doesn't work 8-), and I do not have a way to get the data from it.


link publish delete flag offensive edit

answered 2007-02-22 12:56:14 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


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

By: henrichen

try

<h:input type="file" onChange="...."/>

/henri

link publish delete flag offensive edit

answered 2007-02-23 05:30:15 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


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

By: lubosp

Thanks Henri,

I am almost there. But now I do have a problem to save the value in onChange or zk:onChange. None of them recognizes zk id.
For example (same problem if I use just onChange:

<textbox id="exportlabel" value=""/>
<h:input id="exportfile" type="file" size="50"
zk:onChange="exportlabel.value=self.value"/>

I will get error that exportlabel is unknown.
How do I get the filename from the <h:input type="file">?

Sorry to bother you so much with this and thanks for all your help.


link publish delete flag offensive edit

answered 2007-02-23 08:13:10 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


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

By: henrichen

Try use full Java syntax.

self.getFellow("exportlabel").setValue(self.getValue());

/henri

link publish delete flag offensive edit

answered 2007-02-23 15:16:53 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


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

By: lubosp

That doesn't work, it fails with error: object doesn't support this property or method (with either zk:onChange or h:onChange).

I only can get the input file value with h:onChange, like this:
<h:input id="exportfile" type="file" size="50"
h:onChange="alert(exportfile.value)"/>

but then I cannot save the value, because h:onChange does not know ZK context/ids:

<label id="exportlabel" value="File to export to:"/> <h:input id="exportfile" type="file" size="50"
h:onChange="exportlabel.value=exportfile.value"/>

I get exportlabel is undefined.

Looking at HTML source, the HTML id for exportlabel is id="_pc6h".

How do I get from h: space to zk: space.

I look at user's guide 2.3 on page 148 example, which uses zk:onChange:

<input id="inp0" type="text" zk:onChange="add()"/> + <input id="inp1" type="text" zk:onChange="add()"/> = <text id="out"/> <zscript> void addItem() { Component li = new Raw("li"); li.setParent(ul); new Text("Item "+ul.getChildren().size()).setParent(li);
}
void add() {
out.setValue(inp0.getValue() + inp1.getValue()); } </zscript>

But that fails for me (inp0, inp1 is not known) but this is zhtml not zul example.

I promise, I will add this to FAQ if we can resolve it 8-).


link publish delete flag offensive edit

answered 2007-02-24 04:11:32 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


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

By: henrichen

I tried this on ZK live demo and it works.

/henri


<window title="mix HTML demo" xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:zk="http://www.zkoss.org/2005/zk">
<textbox id="exportlabel" value=""/>
<h:input id="exportfile" type="file" size="50"
zk:onChange="exportlabel.value=self.value"/>
</window>


link publish delete flag offensive edit

answered 2007-02-24 15:07:44 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


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

By: lubosp

Thanks Henri,

as always you are right. The problems was the clash of the name spaces. Here is what I had:

xmlns="http://www.zkoss.org/2005/zul"
xmlns:zk="http://www.zkoss.org/2005/zul"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.zkoss.org/2005/zul
http://www.zkoss.org/2005/zul/zul.xsd"
xmlns:h="http://www.w3.org/1999/xhtml"

Notice xmlns="http://www.zkoss.org/2005/zul" and xmlns:zk="http://www.zkoss.org/2005/zul" point to the same namespace and that causes the problem. If I replace it with:

<zk xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:zk="http://www.zkoss.org/2005/zk">

it works! Thanks for all your help and patience.


link publish delete flag offensive edit

answered 2010-05-21 21:10:12 +0800

jlm1016 gravatar image jlm1016
6

I am chinese,i get some help from the problem,Thank you!i am poor Englist!
I love the dialogue!

link publish delete flag offensive edit

answered 2010-09-07 22:25:34 +0800

sxz gravatar image sxz
3

hi:

I have a proplem about ZK

this is the proplem
SEVERE: >>java.lang.IllegalArgumentException: java.lang.ClassCastException@1134c4b


when we click the upload ,it will appeal. I dont't konw why?

Anybody can help me ,thanks!


<?page title="Upload File" contentType="text/html;charset=UTF-8"?>
<zk>
<zscript><![CDATA[
Component comp;
import org.zkoss.zk.ui.util.Configuration;
]]></zscript>

<borderlayout height="200px">
<west size="10%" border="none"></west>
<center>
<window title="Upload File" border="normal" id="uploadWin"
xmlns:h="http://www.w3.org/1999/xhtml"
apply="com.test.pam.UploadController">
<vbox>
<hbox>
<h:input id="exportfile" type="file" size="30" />
</hbox>
<hbox>
<button label="Upload" id="fileupload">

<attribute name="onClick">
<![CDATA[
Desktop desktop = self.getDesktop();
Configuration conf = desktop.getWebApp().getConfiguration();
conf.setMaxUploadSize(1024);
conf.setUploadCharset("gbk");
]]>
</attribute>
</button>
<button label="Cancel" />


</hbox>

</vbox>
</window>
</center>
<east size="10%" border="none"></east>
</borderlayout>
</zk>

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-02-20 22:35:22 +0800

Seen: 2,222 times

Last updated: Sep 21 '10

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