Jsf 2 有没有办法在高级模式和自动模式下隐藏Primefaces文件上载进度条和按钮?
有没有办法在高级模式和自动模式下隐藏Primefaces文件上载进度条和按钮 以下是我正在使用的代码:Jsf 2 有没有办法在高级模式和自动模式下隐藏Primefaces文件上载进度条和按钮?,jsf-2,primefaces,Jsf 2,Primefaces,有没有办法在高级模式和自动模式下隐藏Primefaces文件上载进度条和按钮 以下是我正在使用的代码: <p:fileUpload id="scriptUpload" widgetVar="importDevicesWidget" fileUploadListener="#{scriptUploadBean.handleFileUpload}"
<p:fileUpload id="scriptUpload"
widgetVar="importDevicesWidget"
fileUploadListener="#{scriptUploadBean.handleFileUpload}"
auto="true"
label="Choose.."
mode="advanced"
update=":infoMessages"
sizeLimit="8192"
allowTypes="/(\.|\/)(txt)$/"
onstart="clearInvalidFileMsg();$('#progress').show();"
oncomplete="clearInvalidFileMsg();$('#progress').hide();importDevicesDialogWidget.hide()"/>
问题是,每个文件的进度条旁边出现的按钮没有意义,因为模式是自动的,所以上传已经开始了
以下是屏幕截图:
嗯,我喜欢能回答我自己的问题: 以下是更新的代码:
<p:dialog appendToBody="true" id="importDevices" widgetVar="importDevicesDialogWidget" header="Import Devices" resizable="false" modal="true" onShow="centerDialog('#importDevicesDialog');">
<h:form id="importDevicesForm" enctype="multipart/form-data">
<h:panelGrid columns="1" cellpadding="5">
<p:fileUpload id="scriptUpload"
widgetVar="importDevicesWidget"
fileUploadListener="#{scriptUploadBean.handleFileUpload}"
auto="true"
label="Choose.."
mode="advanced"
update=":infoMessages"
sizeLimit="8192"
allowTypes="/(\.|\/)(txt)$/"
onstart="clearInvalidFileMsg();$('#progress').show();"
oncomplete="clearInvalidFileMsg();$('#progress').hide();importDevicesDialogWidget.hide()"/>
<p:spacer height="10px;"/>
<p:commandButton value="Cancel" action="javascript.void(0);" onclick="clearInvalidFileMsg();importDevicesDialogWidget.hide();"/>
</h:panelGrid>
</h:form>
</p:dialog>
根据3.4文档
.ui fileupload.start
,.ui fileupload.cancel
和.ui fileupload.progress
选择文件上传的开始、取消和进度条:
<style type="text/css">
.ui-fileupload .start {
display: none;
}
.ui-fileupload .cancel {
display: none;
}
.ui-fileupload .progress {
display: none;
}
</style>
.ui文件上载。开始{
显示:无;
}
.ui文件上载。取消{
显示:无;
}
.ui文件上载。进度{
显示:无;
}
对于PrimeFaces 5这可能是一个解决方案(使用atm)
然后在你的
fileupload
组件中使用fileupload simple
类,你就可以开始了:)为我工作。Primefaces 6.0.1
<style type="text/css">
.ui-fileupload-content .ui-progressbar {
width: 0px;
height: 0px;
margin: 0
}
</style>
.ui文件上载内容.ui进度栏{
宽度:0px;
高度:0px;
保证金:0
}
在文件上载标记中使用showButtons=“false”
例如:
好吧,有一个干净的css解决方案可以解决您的问题,它可以避免不必要的样式设计对后端代码的污染。@akoskm,请分享它here@kolossus当然,请参见上面我的解决方案,这取决于模式-例如,使用mode=“advance”,类将是,fileupload files当前版本的PrimeFaces中没有这样的属性。这在PrimeFaces 8中也适用
.fileupload-simple > .ui-fileupload-content {
display: none;
}
.fileupload-simple > .ui-fileupload-buttonbar {
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
<style type="text/css">
.ui-fileupload-content .ui-progressbar {
width: 0px;
height: 0px;
margin: 0
}
</style>