Jsf 通过p:remoteCommand将参数从xhtml传递到JavaBean不起作用
我正在使用Jsf 通过p:remoteCommand将参数从xhtml传递到JavaBean不起作用,jsf,primefaces,remotecommand,Jsf,Primefaces,Remotecommand,我正在使用p:fileUpload组件,我需要从该组件传递到JavaBean类,即将上载的文件数。 文件计数在这里可用PrimeFaces.widgets..files.length。 所以我试图通过p:remoteCommand将这个值传递给JavaBean,但由于某种原因,调用了操作中定义的方法,但没有传递参数 我用的是PrimeFaces2.1。。。我知道这是史前版本,但我需要修复应用程序中使用此版本Primefaces的一个错误。因此,不可能升级到新版本 这是我的代码片段 XHTML:
p:fileUpload
组件,我需要从该组件传递到JavaBean类,即将上载的文件数。
文件计数在这里可用PrimeFaces.widgets..files.length
。
所以我试图通过p:remoteCommand
将这个值传递给JavaBean,但由于某种原因,调用了操作中定义的方法,但没有传递参数
我用的是PrimeFaces2.1。。。我知道这是史前版本,但我需要修复应用程序中使用此版本Primefaces的一个错误。因此,不可能升级到新版本
这是我的代码片段
XHTML:
<p:fileUpload
fileUploadListener="#{staticView.handleSingleFileUpload}"
mode="advanced" multiple="true" id="upload"
widgetVar="fileUploadWidget"
label="#{text['forms.filesView.upload']}"
uploadLabel="#{text['forms.filesView.doUpload']}"
cancelLabel="#{text['forms.filesView.doCancel']}"
dragDropSupport="true"
update="@form :editorForm:msgs :editorForm:filesDetail"
onstart="setFilesCount({filesCount:PrimeFaces.widgets.fileUploadWidget.files.length});">
</p:fileUpload>
<p:remoteCommand name="setFilesCount" action="#{staticView.setFilesCountSelectedForUpload}" />
public void setFilesCountSelectedForUpload() {
String countInString = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("filesCount");
filesCountSelectedForUpload = Integer.parseInt(countInString);
}
public void handleSingleFileUpload(FileUploadEvent event) {
try {
UploadedFile file = event.getFile();
processFileUpload(file);
} finally {
filesCountSelectedForUpload--;
if (filesCountSelectedForUpload <= 0) {
enableOverwrite();
}
}
}
Javabean:
<p:fileUpload
fileUploadListener="#{staticView.handleSingleFileUpload}"
mode="advanced" multiple="true" id="upload"
widgetVar="fileUploadWidget"
label="#{text['forms.filesView.upload']}"
uploadLabel="#{text['forms.filesView.doUpload']}"
cancelLabel="#{text['forms.filesView.doCancel']}"
dragDropSupport="true"
update="@form :editorForm:msgs :editorForm:filesDetail"
onstart="setFilesCount({filesCount:PrimeFaces.widgets.fileUploadWidget.files.length});">
</p:fileUpload>
<p:remoteCommand name="setFilesCount" action="#{staticView.setFilesCountSelectedForUpload}" />
public void setFilesCountSelectedForUpload() {
String countInString = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("filesCount");
filesCountSelectedForUpload = Integer.parseInt(countInString);
}
public void handleSingleFileUpload(FileUploadEvent event) {
try {
UploadedFile file = event.getFile();
processFileUpload(file);
} finally {
filesCountSelectedForUpload--;
if (filesCountSelectedForUpload <= 0) {
enableOverwrite();
}
}
}
public void setfilescontselectedforupload(){
String countInString=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(“文件计数”);
filescontselectedforupload=Integer.parseInt(countInString);
}
public void handleSingleFileUpload(FileUploadEvent事件){
试一试{
UploadedFile=event.getFile();
processFileUpload(文件);
}最后{
选择用于上载的文件计数--;
如果(文件数)选择上载