rendered paste body/*
* UnidadeMBean.java
*
* Created on 10 de Dezembro de 2007, 12:44
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package br.unp.sisPedidos.controle;
import br.unp.sisPedidos.dao.DAOUtils;
import br.unp.sisPedidos.dominio.Unidade;
import java.util.Date;
import java.util.List;
import javax.el.ELContext;
import javax.el.ValueExpression;
import javax.faces.component.UIParameter;
import javax.faces.component.html.HtmlColumn;
import javax.faces.component.html.HtmlCommandButton;
import javax.faces.component.html.HtmlCommandLink;
import javax.faces.component.html.HtmlDataTable;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
/**
*
* @author KCT
*/
public class UnidadeMBean {
private Unidade objUnidade = new Unidade();
private UIParameter paramId = new UIParameter();
/** Creates a new instance of UnidadeMBean */
public UnidadeMBean() {
}
public String salvar(){
objUnidade.setDataoperacao(new Date());
DAOUtils dao = new DAOUtils();
dao.persist(getObjUnidade());
dao.closeSession();
return null;
}
public List<Unidade> getAll(){
return (List<Unidade>) new DAOUtils().findAll(Unidade.class);
}
public String deletar(){
objUnidade.setIdunidade((Integer)paramId.getValue());
new DAOUtils().delete(objUnidade);
objUnidade = new Unidade();
return null;
}
public String selecionar(){
Integer id = (Integer) paramId.getValue();
objUnidade = (Unidade) new DAOUtils().findById(Unidade.class,id);
return null;
}
public Unidade getObjUnidade() {
return objUnidade;
}
public void setObjUnidade(Unidade objUnidade) {
this.objUnidade = objUnidade;
}
public UIParameter getParamId() {
return paramId;
}
public void setParamId(UIParameter paramId) {
this.paramId = paramId;
}
}