0

upload event dialog do not open in browser

asked 2016-12-18 17:03:28 +0800

npu3pak gravatar image npu3pak
1

when I put button <button id="btn_add_files" upload="true" ...="" into="" <div="" visible="false" ...="" >="" and="" click="" on="" this="" button="" next="" in="" my="" sat,="" after="" make="" div="" visible="true" ,="" openfiledialog="" doesn't="" show="" ...="" can="" you="" help="" me="" pls="" <="" p="">

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-12-19 13:41:42 +0800

Darksu gravatar image Darksu
1991 1 4

Hello npu3pak,

Please use the following example:

<zk>
  <window apply="org.zkoss.bind.BindComposer"
    viewModel="@id('vm') @init('pkg$.TestViewModel')">
      <checkbox label="checkme" visible="@load(true, before='show') @load(false, before='hide')"/>
      <button label="show" onClick="@command('show')"/>
      <button label="hide" onClick="@command('hide')"/>

      <div visible="@load(true, before='show') @load(false, before='hide')" >
        <button id="upload" label="upload" upload="true"/>
    </div>
  </window>
</zk>

Java

package pkg$;

import java.util.ArrayList;
import java.util.List;

import org.zkoss.util.media.Media;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Messagebox;

public class TestViewModel {

  @Listen("onUpload = button#upload")
    public void onUpload(UploadEvent event) {
        try {
            System.out.println("before upload " + event.getMedia().getName());
            Media media = event.getMedia();
            Clients.showNotification("upload details: " + 
                    " name " + media.getName() +
                    " size " + (media.isBinary() ? media.getByteData().length : media.getStringData().length()) +
                    " type " + media.getContentType());
            System.out.println("after upload " + event.getMedia().getName());
        } catch (Exception e) {
            e.printStackTrace();
            Messagebox.show("Upload failed");
        }
    }


  @Command({"show","hide"})
    public void foobar(){
    }
}

Best Regards,

Darksu

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2016-12-18 17:03:28 +0800

Seen: 32 times

Last updated: Dec 19 '16

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