Angularjs and JSTL Master-Detail

Asked

Viewed 350 times

0

Good afternoon, you guys.

Next, I’m using Angularjs to add the details of a sale, but on the server side I’m using Spring MVC with JSTL foreach the details to add on the server.

HTML that rescues details and traverses elements:

                    <tr id='addr0' items ng-repeat="item in invoice.items">
                            <ec:inputText path="itens[${loop.index}].venda.oid" visible="false" />
                            <ec:inputText path="itens[${loop.index}].oid" visible="false" />
                            <c:forEach items="${venda.itens}" varStatus="loop">
                                <td><ec:inputSelect2 dataUrl="/cadastros/item"
                                        onlyComp="true" dataText="descricao" dataId="oid"
                                        path="itens[${loop.index}].item.oid" /></td>
                                <td><ec:inputText onlyComp="true"
                                        id="venda.itens.quantidade[${loop.index}]" path="itens[${loop.index}].quantidade" /></td>
                                <td><ec:inputDecimal path="itens[${loop.index}].valorUnitario"
                                        onlyComp="true" /></td>
                                <td><ec:inputDecimal path="itens[${loop.index}].valorTotal"
                                        onlyComp="true" /></td>
                                <td><a href class='btn-delete pull-right btn btn-default'
                                    ng:click='removeItem(${loop.index})'><spring:message
                                            code='venda.deletar.item' /></a></td>
                            <tr id='addr${fn:length(venda.itens)}'/>
                        </c:forEach>
                        </tr>

HTML using Angularjs that generates the details and assigns the index to Spring MVC and HTML elements:

<td><input ng-model='item.descricao' data-url='${pageContext.request.contextPath}/cadastros/item' data-id='oid' data-text='descricao' name='teste{{$index}}' id='teste{{$index}}' type='select2' name = 'itens[{{$index}}].produto.oid' style=' min-width: 150px;' class='form-control' /></td><td><input name = 'itens[{{$index}}].quantidade' ng-model='item.quantidade' type='text'  class='form-control input-md'></td><td><input name = 'itens[{{$index}}].valorUnitario' type='text' ng-model='item.valorUnitario'  class='form-control input-md'></td><td><input name = 'itens[{{$index}}].valorTotal' value='{{ item.quantidade * item.valorUnitario }}' type='text' readonly  class='form-control input-md'></td><td><a href class='btn-delete pull-right btn btn-default' ng:click='removeItem($index)'><spring:message code='venda.deletar.item' /></a></td>

The HTML is normally built, but when the user clicks to save the information from the list, or rather, from the detail, do not go to the server, although the index is correct and I believe that this would not be a good practice and I would like to know the best solution that you would give me. Preferably you don’t need AJAX to save either the master or the details.

Necessarily everything that is built with Angularjs needs to be used the Angularjs tools to be sent to the server or can I let JSP take care of the work? I have to use only one of the tools (JSTL or Angularjs) to account for the work?

Thank you in advance.

  • I don’t know anything about jstl, so I can’t really understand how things are working. Could post the final HTML (client-side)?

  • Is JSTL correct? There is one tr emptiness within another tr. As for js, some error is logged in to the console?

No answers

Browser other questions tagged

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