如何在 ADF 中提交带有文件的表单后重置表单中的输入文件
How to reset the inputfile in form after submitting the form with a file in ADF
我有一个表单,其中有 3 个输入字段和一个 af:inputFile 我需要上传文件并最终保存的字段。
我不能将 valueChangeEvent 用于 inputFile,因为如果我使用 ResetUtils,那么我将无法获得表单输入值。
保存时一切正常,但是当我再次添加记录时,最后更新的文件仍然显示在 inputFile 中(它没有重置)。
保存后,如果我将输入文件绑定设置为空,然后使用绑定加载页面来对组件进行部分触发,需要花费大量时间来保存,所以我无法使用它。
这是我的代码
<af:panelFormLayout id="pfl1" rows="3">
<af:inputText value="#{bindings.Title.inputValue}" label="#{bindings.Title.hints.label}"
required="#{bindings.Title.hints.mandatory}"
columns="#{bindings.Title.hints.displayWidth}"
maximumLength="#{bindings.Title.hints.precision}"
shortDesc="#{bindings.Title.hints.tooltip}" id="it1" contentStyle="width:150px">
<f:validator binding="#{bindings.Title.validator}"/>
</af:inputText>
<af:panelGroupLayout id="pgl350" layout="horizontal">
<af:inputFile label="Select" id="if51" value="#{ContractDocumentUploadDwn.file}"
showRequired="true" binding="#{ContractDocumentUploadDwn.inputFileBinding}"/>
<af:button text="Upload" id="b353" action="#{ContractDocumentUploadDwn.uploadPortfolioDoc}"/>
</af:panelGroupLayout>
</af:panelFormLayout>
Java代码:
public void savePortfolioDoc(ActionEvent actionEvent) {
// Add event code here...
DCIteratorBinding iter = getDCIteratorBinding("portfolioDocument1Iterator");
UploadedFile myfile = (UploadedFile) this.getInputFileBinding().getValue();
String binding = "Commit1";
String popUpId = "p2";
genericSaveDocuments(actionEvent, iter, myfile, binding, popUpId, "Portfolio");//Saves the document
iter.executeQuery();
iter.refresh(1);
setInputFileBinding(null);
ResetUtils.reset(actionEvent.getComponent());
}
这不是你在 https://community.oracle.com/thread/3889350
提出的问题吗
你试过那里给出的解决方案了吗?
public void savePortfolioDoc(ActionEvent actionEvent) {
// Add event code here...
DCIteratorBinding iter = getDCIteratorBinding("portfolioDocument1Iterator");
UploadedFile myfile = (UploadedFile) this.getInputFileBinding().getValue();
String binding = "Commit1";
String popUpId = "p2";
genericSaveDocuments(actionEvent, iter, myfile, binding, popUpId, "Portfolio");//Saves the document
this.getInputFileBinding().resetValue();
this.setFile(null);
// Reset inputFile component after upload
ResetUtils.reset(this.getInputFileBinding());
//iter.executeQuery();
//iter.refresh(1);
}
enter image description here只需转到上传按钮所在的弹出窗口即可。
然后在属性 "Content Delivery" 中设置为 lazyUncache
"ChildChildren" 设置为 立即
"Auto Cancel" 设置为 禁用
最后
"ResetEditableValues" 设置为 WhenCancel
它会正常工作
快乐编码:)
我有一个表单,其中有 3 个输入字段和一个 af:inputFile 我需要上传文件并最终保存的字段。 我不能将 valueChangeEvent 用于 inputFile,因为如果我使用 ResetUtils,那么我将无法获得表单输入值。 保存时一切正常,但是当我再次添加记录时,最后更新的文件仍然显示在 inputFile 中(它没有重置)。 保存后,如果我将输入文件绑定设置为空,然后使用绑定加载页面来对组件进行部分触发,需要花费大量时间来保存,所以我无法使用它。
这是我的代码
<af:panelFormLayout id="pfl1" rows="3">
<af:inputText value="#{bindings.Title.inputValue}" label="#{bindings.Title.hints.label}"
required="#{bindings.Title.hints.mandatory}"
columns="#{bindings.Title.hints.displayWidth}"
maximumLength="#{bindings.Title.hints.precision}"
shortDesc="#{bindings.Title.hints.tooltip}" id="it1" contentStyle="width:150px">
<f:validator binding="#{bindings.Title.validator}"/>
</af:inputText>
<af:panelGroupLayout id="pgl350" layout="horizontal">
<af:inputFile label="Select" id="if51" value="#{ContractDocumentUploadDwn.file}"
showRequired="true" binding="#{ContractDocumentUploadDwn.inputFileBinding}"/>
<af:button text="Upload" id="b353" action="#{ContractDocumentUploadDwn.uploadPortfolioDoc}"/>
</af:panelGroupLayout>
</af:panelFormLayout>
Java代码:
public void savePortfolioDoc(ActionEvent actionEvent) {
// Add event code here...
DCIteratorBinding iter = getDCIteratorBinding("portfolioDocument1Iterator");
UploadedFile myfile = (UploadedFile) this.getInputFileBinding().getValue();
String binding = "Commit1";
String popUpId = "p2";
genericSaveDocuments(actionEvent, iter, myfile, binding, popUpId, "Portfolio");//Saves the document
iter.executeQuery();
iter.refresh(1);
setInputFileBinding(null);
ResetUtils.reset(actionEvent.getComponent());
}
这不是你在 https://community.oracle.com/thread/3889350
提出的问题吗你试过那里给出的解决方案了吗?
public void savePortfolioDoc(ActionEvent actionEvent) {
// Add event code here...
DCIteratorBinding iter = getDCIteratorBinding("portfolioDocument1Iterator");
UploadedFile myfile = (UploadedFile) this.getInputFileBinding().getValue();
String binding = "Commit1";
String popUpId = "p2";
genericSaveDocuments(actionEvent, iter, myfile, binding, popUpId, "Portfolio");//Saves the document
this.getInputFileBinding().resetValue();
this.setFile(null);
// Reset inputFile component after upload
ResetUtils.reset(this.getInputFileBinding());
//iter.executeQuery();
//iter.refresh(1);
}
enter image description here只需转到上传按钮所在的弹出窗口即可。 然后在属性 "Content Delivery" 中设置为 lazyUncache "ChildChildren" 设置为 立即 "Auto Cancel" 设置为 禁用 最后 "ResetEditableValues" 设置为 WhenCancel 它会正常工作 快乐编码:)