Primefaces:fileUpload显示Facesmessage无法正常工作

问题描述 投票:0回答:1

我正在使用Primefaces上传图片,我想检查图片是否不是太多,但文件uploadListener只检查最大尺寸。我已设法检查文件的大小,但我无法显示任何消息。

我能做什么?

    <p:messages autoUpdate="true" />
        <h:panelGroup>
        <p:fileUpload id="previous" mode="advanced" auto="true"
        fileUploadListener="#{carView.handleImageUpload}"
        dragDropSupport="false" multiple="false" sizeLimit="200000"
        allowTypes="/(\.|\/)(gif|jpe?g|png)$/" update="form"
        style="position: absolute; right: -1.5%;" label="">


</p:fileUpload>

这是一个概括的carView

public void handleImageUpload(FileUploadEvent event) {
    ....
        try {

            if (width <=130 || height <=120) {
                FacesContext.getCurrentInstance().addMessage(null,
                        new FacesMessage(FacesMessage.SEVERITY_ERROR, "file too small"));
     }

FacesMessage永远不会显示。

jsf file-upload primefaces
1个回答
0
投票

实际上由于某些原因,它只是一个CSS问题。快速解决此问题的一个好方法是检查我想要显示的消息是否在html代码中

© www.soinside.com 2019 - 2024. All rights reserved.