English 中文(简体)
t: 输入FileUplod 不上传文件
原标题:t:inputFileUpload not uploading the file

我正用我的脸扩展 Filter 上传一个文件, 但文件并没有被设置到我的豆上, 以供进一步处理 。

以下是代码:

<h:form id="uploadFileForm" enctype="multipart/form-data">
    <tom:inputFileUpload id="file" 
        value="#{paramUpload.uploadFile}">
        <f:valueChangeListener type="com.bosch.de.plcd.plugin.ParamFileUpload" />
    </tom:inputFileUpload>
    <a4j:commandButton value="#{tpMsgs.upload}"
        styleClass="button" action="#{paramUpload.uploadParamFile}"
        onclick="javascript:updateParentScreen();">
    </a4j:commandButton>
</h:form>

Web.xml 配置如下:

<filter>
    <filter-name>Extensions Filter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>Extensions Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

由于 UploadFile 未被设定为豆, 我也尝试使用价值改变倾听器,

豆代码

public class ParamFileUpload implements ValueChangeListener {

    private UploadedFile uploadFile;

    public void uploadParamFile() {
        if(uploadFile != null) {
            LOGGER.info("File type: " + uploadFile.getContentType());
            LOGGER.info("File name: " + uploadFile.getName());
            LOGGER.info("File size: " + uploadFile.getSize() + " bytes");
        }
    }

    public UploadedFile getUploadFile() {
        return uploadFile;
    }

    public void setUploadFile(UploadedFile uploadFile) {
        this.uploadFile = (UploadedFile)uploadFile;
    }

    public void processValueChange(ValueChangeEvent event)
        throws AbortProcessingException {
        this.uploadFile = (UploadedFile) event.getNewValue();
    }
}

你看见我在这里可能漏掉的 任何其他配置吗?

最佳回答

无法用当前 JSF 和 Tomahawk 版本由 ajax 上传文件。 JSF 创建的 Ajax 请求不支持也不使用 < code> multultipart/ form- data 。 Tomahawk 不是一个基于 ajax 的组件库, 而不是使用普通命令按钮 。

<h:commandButton value="#{tpMsgs.upload}"
    styleClass="button" action="#{paramUpload.uploadParamFile}"
    onclick="javascript:updateParentScreen();">
</h:commandButton>

使用 ajax 上传文件的支持 < a href=" http://java.net/jira/browse/ JAVASERVERFACES_SPEC_PUBLIC-802" rel=“nofollow” > programmely 对于即将推出的具有新 组件的 JSF 2. 2 支持。

或者,您可以使用 Richfaces 自己的 。根据所使用的 Richfaces 版本,它使用Flash 或封面下的 irame 黑客来实现非同步文件上传 。

问题回答

暂无回答




相关问题
JSF a4j:support with h:selectManyCheckbox

I m having trouble with a JSF selectManyCheckbox and A4J support. The purpose is to run some action when a checkbox is selected. This works perfectly in Firefox. Yet, when testing in any IE (ie6 / ie7 ...

Mojarra for JSF Encoding

Can anyone teach me how to use mojarra to encode my JSF files. I downloaded mojarra and expected some kind of jar but what i had downloaded was a folder of files i don t know what to do with

如何拦截要求终止?

在共同基金中,如果用户要求终止,就需要采取一些行动。 我需要某种拦截器,但我不知道如何这样做。 我需要帮助。 增 编

ICEFaces inputFile getting the file content without upload

Is there any way of just getting the content of the browsed file without any upload/file transfer operations? I currently use ICEFaces inputFile component but I do not need the default uploading ...

Weird behaviour of h:commandLink action (MethodExpression)

I have two JSPs where I am displaying some info from database in a h:dataTable. One of them is showing all the info, and one of them user specifically. I have showXML.jsp that shows the "XML" column ...

How to correctly use ResultSet with h:dataTable

The problem is, that after displaying the ResultSet with <h:dataTable>, the connection is left open. If I close it, it closes the ResultSet too. I m thinking about copying the ResultSet data ...

热门标签