Passing value to the backing bean with PrimeFaces file upload

南笙酒味 提交于 2019-12-06 15:51:14

Use remoteCommand for this. For e.g.:

<h:form id="idAssessmentsUploadForm" enctype="multipart/form-data">

    <h:panelGrid cellspacing="10" styleClass="standard-panel" columns="2" id="idAssessmentsUploadPanelGrid">

        <h:outputText value="#{msg['application.assessmentsUploadRequest.loader']}"/>
        <p:selectOneMenu id="idLoader"
                         style="width: 230px;"
                         value="#{configurationBean.loaderName}"
                         required="true">

            <f:selectItems value="#{configurationBean.loaders}"/>

        </p:selectOneMenu>

    </h:panelGrid>

    <p:fileUpload fileUploadListener="#{configurationAction.processConfigurationUpload}"
                  allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
                  required="true"
                  onstart="loadProperty()"
                  update="messages"
                  mode="advanced"/>

    <p:remoteCommand name="loadProperty">
        <f:setPropertyActionListener for="idLoader"
                                     value="#{configurationBean.loaderName}"
                                     target="#{configurationBean.loaderName}"/>
    </p:remoteCommand>

</h:form>

Not tested but should work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!