Filling and sending forms with Spring MVC and JSP

Asked

Viewed 667 times

0

I am initiating into Java Web, developing a stock system following Caelum’s Java for Web workbook.

The whole front-end and the persistence layer have already been developed leaving only the control integrating the two, however I am with many doubts when it comes to get the data of the page to treat them, insert in the bank and etc...

For example on the page below, I have the Send Form, according to what the apostille teaches I have to keep the fields named according to the corresponding attributes of the Send class, until then quiet, the problem is that inside the form I have a sub form that corresponds to the class ItemEnvio and a table, where I can insert several items.

My goal is to fill a ArrayList with the items added in this table and the data from the top of the form in a Submit object, send both to controller and it add in the database, is the logic that I use when developing in Java using Swing with JTable and etc..

Can someone give an orientation on how to proceed?

inserir a descrição da imagem aqui

1 answer

0


During this week of research I found and already implemented the solution.

1º The filling and deletion of lines is done by Javascript following the solution proposed by the user devgaspa from the forum on that topic Take the value of the Avascript table and place it in an array
2º In the send function, I filled in a JSON object with all form information, and even an array with table data. This JSON corresponds to the class Envio that within it possesses a ArrayList class ItemEnvio. I sent this JSON to the controller via AJAX request following the solution of this topic https://stackoverflow.com/questions/18524524/passing-json-data-to-a-spring-mvc-controller.
Since all manipulation was done in pure JS, when trying to use AJAX in Jquery, as the solution shows, gave error, so I made the AJAX requests in pure Javascript following this other topic https://stackoverflow.com/questions/24468459/sending-a-json-to-server-and-retrieving-a-json-in-return-without-jquery

Browser other questions tagged

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