传递输入文本值和带有上载的文件上传 [英] Passing input text value with file upload in primefaces

查看:128
本文介绍了传递输入文本值和带有上载的文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,我必须将inputText的值传递到支持bean,该bean将包含文件的版本以及文件的上载. 我一直在尝试使用远程命令来实现它,但是不起作用.

I have the requirement that I have to pass the value of inputText to backing bean which will contain the version of the file along with the file upload. I have been trying to achieve it using remote command but not working.

下面是我的代码:

 <h:form enctype="multipart/form-data" id="uploadForm">
                        <p:growl id="messages" showDetail="true" />
                        <p:outputLabel for="vers" value="File Version:" />
                        <p:inputText id="vers" name="vers"
                            value="#{remoteDeployment.uploadedVersion}" placeholder="1.x.x.x"
                            maxlength="17" required="true"
                            requiredMessage="Version is required." />
                        <p:separator />
                        <p:fileUpload onstart="submitVersion()"
                            fileUploadListener="#{remoteDeployment.upload}" update="messages" >
                            <f:attribute name="terminalSettings" value="#{as}" />
                        </p:fileUpload>


                        <p:remoteCommand name="submitVersion" process="@this vers" />

                    </h:form>

后备bean中用于输入文本的字符串:

String in backing bean for input text :

@ViewScoped
    private String uploadedVersion;
    public String getUploadedVersion() {
        return uploadedVersion;
    }

    public void setUploadedVersion(String uploadedVersion) {
        this.uploade

请帮助,并让我知道是否还有其他方法.

please help and also let me know if there is any other way of doing it.

谢谢

推荐答案

这对我有用.

<h:form enctype="multipart/form-data" id="uploadForm">
    <p:growl id="messages" showDetail="true"/>
    <p:outputLabel for="vers" value="File Version:"/>
    <p:inputText id="vers" name="vers"
                 value="#{remoteDeployment.uploadedVersion}" placeholder="1.x.x.x"
                 maxlength="17" required="true"
                 requiredMessage="Version is required."/>
    <p:separator/>
    <p:fileUpload fileUploadListener="#{remoteDeployment.upload}" update="messages">
        <f:attribute name="terminalSettings" value="#{as}" oncomplete="$('#uploadForm').submit()"/>
    </p:fileUpload>

</h:form>

这篇关于传递输入文本值和带有上载的文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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