Skip to content

Comments

implemented controllers#653

Open
vaniii1 wants to merge 1 commit intomate-academy:masterfrom
vaniii1:hw-web-practice
Open

implemented controllers#653
vaniii1 wants to merge 1 commit intomate-academy:masterfrom
vaniii1:hw-web-practice

Conversation

@vaniii1
Copy link

@vaniii1 vaniii1 commented Jul 23, 2023

No description provided.

Copy link

@okuzan okuzan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate your controllers into packages

Comment on lines +11 to +14
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shound't make changes here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not. that time i amended commit by mistake

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert back to version 17

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is on version 17

@vaniii1 vaniii1 requested a review from okuzan July 24, 2023 11:42
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
driverService.delete(Long.valueOf(req.getParameter("id")));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redirect the user to another page after the operation. Currently, the user will be left on a blank page after a driver is deleted.

manufacturer.setName(name);
manufacturer.setCountry(country);
manufacturerService.create(manufacturer);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add a redirect after creating a Manufacturer. Otherwise, the user will stay on the same page without any feedback.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
manufacturerService.delete(Long.valueOf(req.getParameter("id")));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After deleting a manufacturer, the user should be redirected to a specific page, usually the list of all manufacturers, to confirm the deletion.

Long carId = Long.valueOf(req.getParameter("car_id"));
Driver driver = driverService.get(driverId);
Car car = carService.get(carId);
carService.addDriverToCar(driver, car);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After processing the POST request successfully, it is common practice to redirect the client to a specific URL, rather than leaving them on the current POST URL.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add sendRedirect here too

driver.setName(name);
driver.setLicenseNumber(licenseNumber);
driverService.create(driver);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After executing the 'create' method, the user is not redirected to any page. This might cause confusion for the user as no visual feedback will be provided after submitting the form.

Comment on lines 34 to 41
Car car = new Car();
String carModel = req.getParameter("car_model");
Long manufacturerId = Long.valueOf(req.getParameter("manufacturer_id"));
Manufacturer manufacturer = manufacturerService.get(manufacturerId);
car.setManufacturer(manufacturer);
car.setModel(carModel);
car.setDrivers(new ArrayList<>());
carService.create(car);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to create variables when we plan to use them

Suggested change
Car car = new Car();
String carModel = req.getParameter("car_model");
Long manufacturerId = Long.valueOf(req.getParameter("manufacturer_id"));
Manufacturer manufacturer = manufacturerService.get(manufacturerId);
car.setManufacturer(manufacturer);
car.setModel(carModel);
car.setDrivers(new ArrayList<>());
carService.create(car);
String carModel = req.getParameter("car_model");
Long manufacturerId = Long.valueOf(req.getParameter("manufacturer_id"));
Manufacturer manufacturer = manufacturerService.get(manufacturerId);
Car car = new Car();
car.setManufacturer(manufacturer);
car.setModel(carModel);
car.setDrivers(new ArrayList<>());
carService.create(car);

@vaniii1 vaniii1 force-pushed the hw-web-practice branch 2 times, most recently from baa9deb to 02717b1 Compare July 25, 2023 12:12
@vaniii1 vaniii1 requested a review from olekskov July 25, 2023 12:13
Long carId = Long.valueOf(req.getParameter("car_id"));
Driver driver = driverService.get(driverId);
Car car = carService.get(carId);
carService.addDriverToCar(driver, car);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add sendRedirect here too

driver.setName(name);
driver.setLicenseNumber(licenseNumber);
driverService.create(driver);
resp.sendRedirect("/drivers");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
fix everywhere

@vaniii1 vaniii1 requested a review from okuzan July 26, 2023 23:47
Comment on lines +11 to +14
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert back to version 17

@vaniii1 vaniii1 requested a review from kozhukhovsky July 27, 2023 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants