0% found this document useful (0 votes)
11 views

Hibernate&struts 2

This Java class is a controller that handles adding new product objects to a database. It contains a ProductDao object for data access and a Product object to hold the new product details. The execute method calls the addProduct method on ProductDao to save the new product and then returns SUCCESS. Getter and setter methods are included to inject dependencies and return the Product object.

Uploaded by

Fabiano Farah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Hibernate&struts 2

This Java class is a controller that handles adding new product objects to a database. It contains a ProductDao object for data access and a Product object to hold the new product details. The execute method calls the addProduct method on ProductDao to save the new product and then returns SUCCESS. Getter and setter methods are included to inject dependencies and return the Product object.

Uploaded by

Fabiano Farah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

AddProductController.

java

package br.struts2.controller.product;

import br.hibernate.beans.Product;

public class AddProductController extends ActionSupport {

private static final long serialVersionUID = 1L;

private ProductDao productDao = new ProductDao();


private Product product = new Product();

@Override
public String execute() throws Exception {

productDao.addProduct(product);

return SUCCESS;
}

public ProductDao getProductDao() {


return productDao;
}

public void setProductDao(ProductDao productDao) {


this.productDao = productDao;
}

public Product getProduct() {


return product;
}

public void setProduct(Product product) {


this.product = product;
}

Page 1

You might also like