Package jsf.entity

Source Code of jsf.entity.CoursesController

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package jsf.entity;

import entity.Courses;
import entity.User;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import jpa.controllers.CoursesJpaController;
import jsf.util.JsfUtil;

/**
*
* @author atap
*/
public class CoursesController {
    private Courses course = null;
    private CoursesJpaController jpaController = null;
    private CoursesConverter converter = null;
 
    public CoursesController() {
        FacesContext context = FacesContext.getCurrentInstance();
        jpaController = (CoursesJpaController) context.getApplication().getELResolver().getValue(context.getELContext(), null, "coursesJpa");
        converter = new CoursesConverter();      
    }
   
    public Courses getCourse() {
        if(course == null) {
            course = (Courses)JsfUtil.getObjectFromRequestParameter("jsfcrud.currentCourses", converter, null);
        }
        if(course == null) {
            course = new Courses();
        }
        return course;
    }
   
    public List<Courses> getAllCourses() {
        return jpaController.findCoursesEntities();
    }
   
    public User user;
    public void setAction(User action) {
            this.user = action;
    }

     public String create() {
        try {                                               
            course.setCreaterUserId(user);
            //course.setLectureList(lectureList);
            Date dt = new Date();
            course.setSysdate(dt);
            //course.setCoursetagList(tagList);
            jpaController.create(course);
            return "lectureAdd";
           
        } catch (Exception e) {
            JsfUtil.ensureAddErrorMessage(e, "A persistence error occurred.");
            return null;
        }
    }    
}
TOP

Related Classes of jsf.entity.CoursesController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.