Package eja.controllers

Source Code of eja.controllers.RoleController

package eja.controllers;

import eja.ejb.dao.RoleDao;
import eja.ejb.entities.UserRole;
import java.util.Collection;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

/**
*
* @author fero
*/
@ManagedBean
@RequestScoped
public class RoleController {

    @EJB
    private RoleDao _roleDao;

    @ManagedProperty("#{param['id']}")
    private int id;
    private String name;
    private String description;



    private UserRole _role;

    /** Creates a new instance of Role */
    public RoleController() {
    }

    public Collection<UserRole> getAllRoles() {
        return this._roleDao.getAllRoles();
    }

    public String edit() {
        this._role = (this.id != 0) ? this._roleDao.getRoleById(this.id) : new UserRole();
        this._role.setName(this.name);
        this._role.setDescription(this.description);;

        this._roleDao.saveRole(this._role);
        return "role-details";
    }

    public UserRole getRole() {
        return this._role;
    }

    public void load() {
        this._role = this._roleDao.getRoleById(this.id);
        this.name = this._role.getName();
        this.description = this._role.getDescription();
    }


    // Getters & Setters
    public int getId() {
        return this.id;
    }

    public void setId(int id) {
        if (id == 0)
            return;

        this.id = id;
        this.load();
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


}
TOP

Related Classes of eja.controllers.RoleController

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.