我想创建一个具有 af:inputfile 组件的弹出窗口/对话框,并使用托管 bean 将其保存在服务器路径中。当我使用弹出窗口时,单击上传按钮后文件会变空
我使用 form 做到了这一点,但问题是页面已经使用了另一个表单,因此出现了多个表单错误。
网页:
<af:popup id="p1" contentDelivery="lazyUncached" >
<af:dialog id="d3" type="none" title=""
closeIconVisible="false">
<f:facet name="buttonBar">
<af:group id="g3">
<af:commandButton text="Save" id="cb2"
partialSubmit="true"
actionListener="#{myMB.onSaveAl}"/>
</af:group>
</f:facet>
<af:panelFormLayout id="pfl2">
<af:inputFile value="" id="if1" autoSubmit="true" required="true"
valueChangeListener="#{myMB.browseAndUpload}" showRequired="true"/>
</af:panelFormLayout>
</af:dialog>
托管bean:
public void browseAndUpload(ValueChangeEvent event)
{
// The event give access to an Uploade dFile which contains data about the file and its content
UploadedFile file = (UploadedFile)event.getNewValue();
}
在表单标签中使useUpload =“true”这将解决问题