F
F
fro-do2019-01-27 23:13:37
Java
fro-do, 2019-01-27 23:13:37

Spring. How to automatically fill the form after filling one of the fields?

Hey!
I'm trying to make my first web application, MVC. Idea in the following: in a DB there is a table "Tasks". I have a form for creating / editing tasks, which has the following fields:
- Task number (aka tasks.id);
- Task title (task.title);
- Description of the task (task.description).
I want that when entering the task number into the form, a database search is performed (when the focus on the field is lost) - if there is a task with the same id, the "Title" and "Description" fields are filled.
I suppose that in the controller I need some kind of "checkID", which will return the task to me by id. But how to pass its attributes for filling, I can’t understand ..
Direct your thought please? :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan, 2019-01-28
Hasanly @azerphoenix

You will have the form on the client, and accordingly, java will not help there. You need to send a request to the server using javascript (when the field focus is lost), and if there is a record with the ID you need, fill in the required fields using JS. And the data to be inserted will be in the received response from the server in JSON or XML. Accordingly, this is a POST ajax request and rather @RestController, which will return the response.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question