Updating Products
Start course
Difficulty
Beginner
Duration
2h 34m
Students
238
Ratings
3.6/5
starstarstarstar-halfstar-border
Description

In this course, we will learn the concepts of microservice and spring framework with a focus on Spring Boot.

Learning Objectives

  • Understanding Spring Boot

Intended Audience

  • Beginner Java developers
  • Java developers interested in learning how to Build and Deploy RESTful Web Services
  • Java Developers who want to develop web applications using the Spring framework
  • Java Developers who want to develop web applications with microservices
  • Java Developers who wish to develop Spring Boot Microservices with Spring Cloud

Prerequisites

  • Basic Java knowledge
Transcript

Hello there, dear friends.

In this video, we will implement the product update operation. So, let's get started. To update any product, first, we have to get the product by ID and show values on a new page. First, add a new HTML page and name it UpdateProduct. Now, we can copy from the AddProduct page. Actually, you may use the AddProduct page for this operation if you like, but as I mentioned previously, we are new to Spring. Thus, I want to add another page for better understanding. Now, paste it into the UpdateProduct page. On this page, we have to add a hidden input for the ID field. As you know with ID, we will update our product. Now, open the AdminController. In this page, we need a method to access the UpdateProduct page. This will take an ID parameter. So, like the delete method, we need the path variable property.

Now, mapping will be ("/UpdateProduct/{id}"). Okay, done. Now, open product service implementation. We have to override the getProduct by ID method. In this method, we will call the findById method of the product repository. We don't need to override any methods for updating. To update a product, we will use the save method. Return to the AdminController now. Now, in the update method, we will call the getProduct by ID method. Set product to the model. Now, redirect this page to the admin product list page.

Okay, that's enough. When we run the project with the Update button, we can see the product details. After making changes and pressing the 'Save' button, all changes will be saved. Let's try. Login with admin. Now, I want to update the second one. Look, all details of the product is on the page. Let's change all of them. Now, save. Look, the list page now shows all of the updates. This is how the update process works. We're now done with this video. In the following video, we'll perform a sale operation on the employee product list page. So, I'll see you there.

 

About the Author
Students
2004
Courses
64
Learning Paths
4

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.