PrimeFaces selectManyCheckBox don't work with enctype="multipart/form-data"

642 Views Asked by At

I'm having a problem with a form that has the enctype="multipart/form-data" attribute and the Primefaces <p:selectManyCheckBox>. This is my code:

<f:view xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui" xmlns="http://www.w3.org/1999/xhtml">

<h:head />
<h:body id="expiration-body">
    <h:form id="new-expiration-form">
        <div id="form_cargar_grupo">
        <p:messages id="msgs" />

            <div class="form_cargar">
                <label>Resolución:</label>
                <p:fileUpload value="#{expirationViewEdit.file}"
                        mode="simple" required="false" />
            </div>


            <p:selectManyCheckbox value="#{expirationViewEdit.departamentIds}">
                    <f:selectItem itemLabel="Option1" itemValue="TEST1" />
                    <f:selectItem itemLabel="Option2" itemValue="TEST2" />
            </p:selectManyCheckbox>

        </div>


        <div class="camp_envio">
            <p:commandButton value="Save" actionListener="#{expirationViewEdit.onSave}" ajax="false" />                 
        </div>
    </h:form>
</h:body>

The problem that I'm having is when I select more than one option of the selectManyCheckBox, in my backing bean List there's only one element and after the form is submitted I see that only one check box is selected (the other one gets unselected).

I found out that when I remove the enctype="multipart/form-data" attribute of the form the check boxes work fine but I need that property in order to upload files to the server.

Is there any workaround for this? Or maybe I'm doing something wrong?

Thanks in advance!

0

There are 0 best solutions below