submit part of the form - jsf primefaces

0

I'm trying to post a part of the form but I've already tried it in some ways and I'm still in trouble.

Follow a print from the screen click to see the image

    <h:form id="QuestaoCreateForm">
    <h:panelGroup id="display">
        <p:panelGrid columns="4" rendered="#{questaoController.selected != null}"  layout="grid" styleClass="ui-panelgrid-blank" style="border:0px none; background-color:transparent;">
            <p:outputLabel value="#{bundle.CreateQuestaoLabel_enunciado}" for="enunciado" />
            <p:inputTextarea id="enunciado" rows="6" cols="33" value="#{questaoController.selected.enunciado}" title="#{bundle.CreateQuestaoTitle_enunciado}" required="true" requiredMessage="#{bundle.CreateQuestaoRequiredMessage_enunciado}"/>
            <p:outputLabel value="#{bundle.CreateQuestaoLabel_orientacao}" for="orientacao" />
            <p:inputTextarea id="orientacao" rows="6" cols="33" value="#{questaoController.selected.orientacao}" title="#{bundle.CreateQuestaoTitle_orientacao}" />
            <p:outputLabel value="#{bundle.CreateQuestaoLabel_assunto}" for="assunto" />
            <p:selectOneMenu id="assunto" value="#{questaoController.selected.assunto}" required="true" requiredMessage="#{bundle.EditQuestaoRequiredMessage_assunto}">
                <f:selectItem itemLabel="#{bundle.SelectOneMessage}"  noSelectionOption="true" />
                <f:selectItems value="#{assuntoController.itemsAvailableSelectOne}"
                               var="assuntoItem"
                               itemValue="#{assuntoItem}"/>
            </p:selectOneMenu>
            <p:outputLabel value="#{bundle.CreateQuestaoLabel_tipoQuestao}" for="tipoQuestao" />
            <p:selectOneMenu id="tipoQuestao" value="#{questaoController.selected.tipoQuestao}" required="true" requiredMessage="#{bundle.EditQuestaoRequiredMessage_tipoQuestao}">
                <f:selectItem itemLabel="#{bundle.SelectOneMessage}"  noSelectionOption="true" />
                <f:selectItems value="#{tipoQuestaoController.itemsAvailableSelectOne}"
                               var="tipoQuestaoItem"
                               itemValue="#{tipoQuestaoItem}"/>
            </p:selectOneMenu>
        </p:panelGrid>

        <p:panel header="Associar itens à Questão" >
            <p:panelGrid columns="2" >
                <p:outputLabel value="#{bundle.CreateItemQuestaoLabel_textoItem}" for="textoItem" style="color: red" />
                <p:inputText id="textoItem" value="#{questaoController.itemQuestao.textoItem}" title="#{bundle.CreateItemQuestaoTitle_textoItem}" />

                <p:outputLabel value="Nota:" for="nota"  />
                <p:inputNumber id="nota" value="#{questaoController.itemQuestao.nota}" title="Nota" decimalPlaces="2" />

            </p:panelGrid>


            <p:commandButton id="btn_add" value="Adicionar" update="itens_da_questao,:growl @parent" action="#{questaoController.reinit}" >
                <p:collector value="#{questaoController.itemQuestao}" addTo="#{questaoController.selected.itemQuestaoList}" unique="false"/>
            </p:commandButton>
            <p:commandButton id="btn_reset" value="Limpar" type="reset"/>
        </p:panel>


        <p:panel header="Itens da Questão" id="itens_da_questao" >


            <p:dataTable style="width:200px;" value="#{questaoController.selected.itemQuestaoList}" var="itemQuestao" id="booksTable" rendered="#{not empty questaoController.selected.itemQuestaoList}"  >

                <p:column headerText="Item Adicionado">
                    <h:outputText value="#{itemQuestao.textoItem}" />
                </p:column>

                <p:column headerText="Action">
                    <p:commandLink value="Remove" update=":QuestaoCreateForm:itens_da_questao" process=":QuestaoCreateForm:itens_da_questao">
                        <p:collector value="#{itemQuestao}" removeFrom="#{questaoController.selected.itemQuestaoList}" unique="false"/>
                    </p:commandLink>
                </p:column>

            </p:dataTable>

        </p:panel>

        <p:commandButton actionListener="#{questaoController.create}" action="/jsf/questao/List.xhtml"  value="#{bundle.Save}"  update="display,:growl" 
                         process=":QuestaoCreateForm:enunciado, :QuestaoCreateForm:orientacao, :QuestaoCreateForm:assunto, :QuestaoCreateForm:tipoQuestao"
                         partialSubmit="true"
                         />
        <p:commandButton value="#{bundle.Cancel}" action="/jsf/questao/List.xhtml" immediate="true"/>
    </h:panelGroup>
</h:form>

The ideal would be to work with 2 forms? Forms nested? already tried several ways in the button configuration ..

    
asked by anonymous 16.08.2017 / 01:45

1 answer

0

You can not nest forms in JSF. The save button should save the panelGrid and selected items. To do this add an id to the panelGrid and the save button put ex.: process="@this id_panel_grid_exemplo" @this serves to process the button itself.

You should also add an id to the panel that contains the first two fields and the two buttons: clear and add. The add button should process this id. ex. process="id_exemplo"

In the second step process only the button, since the list will already be in the bean. SEe process should look like this

    
16.08.2017 / 02:16