在primefaces中传递文件上传的输入文本值

时间:2018-05-24 08:17:34

标签: jsf input file-upload primefaces jsf-2

我要求我必须将inputText的值传递给backing bean,它将包含文件的版本以及文件上载。 我一直在尝试使用远程命令来实现它,但没有工作。

以下是我的代码:

 <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中的字符串:

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

    public void setUploadedVersion(String uploadedVersion) {
        this.uploade

请提供帮助,如果还有其他办法可以告诉我。

由于

2 个答案:

答案 0 :(得分:1)

这对我有用。

Select sum(database_value)
 CASE when science_name_short='rhodo'
 THEN 'Rhododendron species'
END AS real_name
from species_data;

答案 1 :(得分:0)

您可以轻松解决您的问题 将 放在 textinput 标签之间就足够了

    <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:ajax />
    </p:inputtext>
                    <p:separator />
                    <p:fileUpload onstart="submitVersion()"
                        fileUploadListener="#{remoteDeployment.upload}" update="messages" >          
                    </p:fileUpload>
                </h:form>