如何从< p:fileUpload>删除上传取消按钮 [英] how to remove upload cancel button from <p:fileUpload>

查看:513
本文介绍了如何从< p:fileUpload>删除上传取消按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的JSF 2.0 - Primefaces应用程序中,我使用我不想拥有

In my JSF 2.0 - Primefaces application I am using I DO NOT want to have


  1. 进度条

  2. 上传按钮

  3. 取消按钮
    (选择图片时显示在选定图片的旁边)

另一个问题是'fileLimit'我想把它设置为1,但是当我说它无效的属性。

Another issue is the 'fileLimit' I want to set it to 1 but when I do that it says invalid attribute.

这是我的代码:

<p:fileUpload id="related_image" fileUploadListener="#{fileUploadController.handleFileUpload}"  
        mode="advance"  
        auto="false" 
        showButtons="false"
        sizeLimit="100000"
        fileLimit ="1"
        allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
        style="width: 310px"/>


推荐答案

基本上你需要做的是分配find out右侧的选择器,并用 display:none; 设置它们(将它们放在.css文件中, < h:outputStylesheet )

Basically all you have to do is to assign find out the right css selectors and set them with display:none; (put them in your .css file and include it with <h:outputStylesheet)

一般来说(在css中,您需要转义< $ c> \3a 在CSS选择器中处理元素ID中的冒号,而在jquery中,您应该使用 \\:

in general (in css you need to escape the colon with \3a Handling a colon in an element ID in a CSS selector , while in jquery you should use \\:)

#some_prefix_id\3a your_file_upload_component_id .someClass{
    display:none;
}




其中some_prefix_id可能是某种形式一些命名
容器ID,

where the some_prefix_id might be some form id or some naming container id ,

或者(有时在* your_file_upload_component_id *之前没有前缀)

or (sometimes there is no prefix before *your_file_upload_component_id* )

#your_file_upload_component_id .someClass{
    display:none;
}

虽然INMO最好的方法是为你的表单分配一个id, css中的此选择器:

Although , INMO , best approach would be assigning an id to your form and using this selector in css :

#your_form_id .someClass{
    display:none;
}

现在可以选择精确的选择器...

Now to the exact selectors...

以移除上传按钮

#related_image .start{
    display:none;
}

或者如果你想对jquery做同样的操作

or if you want to do the same with jquery

$("#related_image .start").hide();

可删除与所选图像相邻的取消按钮

to remove the cancel button which shows up adjacent to the selected image(once the image is selected)

#related_image .cancel{
    display:none;
}

或者如果你想对jquery做同样的操作

or if you want to do the same with jquery

$("#related_image .cancel").hide();

删除进度栏

#related_image .progress{
    display:none;
}

或者如果你想对jquery做同样的操作

or if you want to do the same with jquery

$("#related_image .progress").hide();

你可以测试jquery方法在primfaces showcase如果你想,只是替换 $(#j_idt19 \\:)的 j_idt20 .start)。hide();

You can test the jquery approach on primefaces showcase if you want , just replace the #related_image with #j_idt19\\:j_idt20 for example $("#j_idt19\\:j_idt20 .start").hide();

code> fileLimit 查看标记文件上传

There is no such attribute as fileLimit take a look at the Tag fileUpload

这篇关于如何从&lt; p:fileUpload&gt;删除上传取消按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆