java - 文件类型 Vaadin Paper Input 中的文件浏览窗口打开操作会触发哪个事件

标签 java gwt polymer vaadin polymer-1.0

我想排除文件类型 Vaadin Paper Input 的“选择文件”按钮,并使用标准 Vaadin Paper Input 执行相同的操作 即,单击标准 Vaadin Paper Input 时,我希望打开浏览器窗口。

我尝试从标准 Vaadin Paper Input 的点击事件中模拟 File 类型的 Vaadin Paper Input 的点击事件和焦点事件。 焦点和单击均按预期正常工作,但浏览器窗口未打开。

我的原型(prototype)代码如下所示,通过这段代码,我能够模拟焦点事件。同样,我尝试了点击事件,但没有达到我的期望。

    final PaperInput text = new PaperInput();
    text.setLabel("Text Box");
    text.setAlwaysFloatLabel(true);


    final PaperInput filePaperInput = new PaperInput();
    filePaperInput.setLabel("File");
    filePaperInput.setType("file");
    filePaperInput.setAlwaysFloatLabel(true);


    text.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {             
            filePaperInput.getElement().<InputElement> cast().focus();
        }
    });

最佳答案

polymer 元素文档如下:

A paper-input can use the native type=search or type=file features. However, since we can't control the native styling of the input (search icon, file button, date placeholder, etc.), in these cases the label will be automatically floated. The placeholder attribute can still be used for additional informational text.

话虽如此,我不确定是否可以将其从容器中取出。

也请阅读此内容:

为什么无法以编程方式触发文件输入选择?

Most browsers prevent submitting files when the input field didn't receive a direct click (or keyboard) event as a security precaution. Some browsers (e.g. Google Chrome) simply prevent the click event, while e.g. Internet Explorer doesn't submit any files that have been selected by a programmatically triggered file input field. Firefox 4 (and later) is so far the only browser with full support for invoking "click"-Events on a completely hidden (display: none) file input field.

关于java - 文件类型 Vaadin Paper Input 中的文件浏览窗口打开操作会触发哪个事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39770578/

相关文章:

java - Optional.orElse(null) 用 org.jetbrains.annotations.NotNull 标记

java - 获取 URL 查询参数 GWT

java - GXT3 - 文本字段高度。如何让TextFields的高度变大?

html - Polymer HTML 导入缓存

javascript - 将 Parse.com 与 Polymer 结合使用

java - 负载测试多线程系统与使用单独进程的系统 - 为什么线程版本要快得多?

java - 对泛型类型进行子类化,从另一个类中的方法返回子类的实例

dart - 安装核心元素和 polymer UI元素时出错

java - spring 批处理仍处于 EXECUTING 状态

ajax - GET for Clojure的不错替代品