View Javadoc

1   /*
2    * Created on Oct 21, 2004
3    *
4    * TODO To change the template for this generated file go to
5    * Window - Preferences - Java - Code Style - Code Templates
6    */
7   package ch.ledcom.hephaistos;
8   
9   import net.sf.hibernate.HibernateException;
10  import net.sf.hibernate.Session;
11  
12  import org.apache.log4j.Logger;
13  import org.apache.struts.action.ActionForm;
14  
15  import ch.ledcom.hephaistos.abstractActions.HibernateAddAction;
16  import ch.ledcom.hephaistos.dao.ProductClass;
17  
18  
19  /***
20   * @author gehel
21   *
22   * @struts.action
23   *  name="productClassForm"
24   *  path="/ProductClassAdd"
25   *  validate="true"
26   *  input="/pages/productClassAdd.jsp"
27   * @struts.action-forward
28   *  name="success"
29   *  path="/index.jsp"  
30   * @struts.action-forward
31   *  name="failure"
32   *  path="/pages/productClassAdd.jsp"
33   */
34  public class ProductClassAddAction extends HibernateAddAction {
35    private static final Logger logger = Logger
36    .getLogger(ProductClassAddAction.class);
37  
38    /* (non-Javadoc)
39     * @see ch.ledcom.hephaistos.HibernateAddAction#doAdd(org.apache.struts.action.ActionForm, net.sf.hibernate.Session)
40     */
41    protected void doAdd(ActionForm form, Session session)
42        throws HibernateException {
43      logger.debug("Casting the ActionForm to ProductClassForm");
44      ProductClassForm productClassForm = (ProductClassForm) form;
45  
46      logger.debug("Creating a new Committee object and populate it");
47      ProductClass productClass = new ProductClass();
48      productClass.setNo(productClassForm.getNo());
49      productClass.setNameF(productClassForm.getNameF());
50      productClass.setNameD(productClassForm.getNameD());
51      
52      logger.info("Saving the new product class");
53      session.save(productClass);
54  
55    }
56  
57  }