submit part of the form - jsf primefaces

Asked

Viewed 341 times

0

I am trying to post a part of the form but I have tried it in some ways and I still have problems.

Follow a screen print 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 ? Nested forms ? I have tried several ways in setting the boot..

  • It would be interesting [Dit] your answer with more information, not everyone will be able to open the image to be able to help you

1 answer

0


You cannot nest Forms in JSF. The save button should save the Rid panelGrid and the items already chosen. To do this add an id to the Rid panelGrid and the save button put ex.:process="@this id_panel_grid_exemplo" @this is for processing the button itself.

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.