How I can manage a global form and specific form on the same dataTable?

96 Views Asked by At

I have the next code on my JSF page:

<b:dataTable value = "#{formBean.formularios}" var = "formulario" id = "dataTableFormularios">
    <p:column>
        <f:facet name = "header">
            <h:outputText value = "Nombre Formulario"/>
        </f:facet>
        <h:form>
            <p:commandLink update = "..." process="@this" action="..." value = "#{formulario.nombre}"/>
        </h:form>                            
    </p:column>
</b:dataTable>

My goal: I want to provide the user the ability to remove some records from the table simultaneously and without much effort. What do you recommend me to do?

My proposal: Use b:selectBooleanCheckbox with a button and cover all this in a <h:form>.

The problem with my proposal: In order to cover all selectBooleanCheckbox with a button, I think it should also cover the entire table. If I recubro entire table would have a structure failure by the <h:form> of <p:commandLink>:

<h:form>
    <b:dataTable value = "#{formBean.formularios}" var = "formulario" id = "dataTableFormularios">
        <p:column>
            <f:facet name = "header">
                <h:outputText value = ""/>
            </f:facet>
                <b:selectBooleanCheckbox value = "{#formulario.id}"/>
        </p:column>
        <p:column>
            <f:facet name = "header">
                <h:outputText value = "Nombre Formulario"/>
            </f:facet>
            <h:form>
                <p:commandLink update = "..." process="@this" action="..." value = "#{formulario.nombre}"/>
            </h:form>                            
        </p:column>
    </b:dataTable>
    <b:commandButton .../>
</h:form>
1

There are 1 best solutions below

0
On

Just wrap your whole dataTable with a form like you did and remove all other form elements inside your dataTable. The commandLink within the dataTable will still work