gpt4 book ai didi

jsf - 在 primefaces 中通过文件上传传递输入文本值

转载 作者:行者123 更新时间:2023-12-02 12:56:46 24 4
gpt4 key购买 nike

我要求必须将 inputText 的值传递给支持 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

请帮忙,并让我知道是否有其他方法可以做到这一点。

谢谢

最佳答案

这对我有用。

<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>

关于jsf - 在 primefaces 中通过文件上传传递输入文本值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50504313/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com