
package acciones;

import static com.opensymphony.xwork2.Action.INPUT;
import static com.opensymphony.xwork2.Action.SUCCESS;
import com.opensymphony.xwork2.ActionSupport;
import entidad.Categoria;
import java.util.List;
import servicio.ServicioCategoria;

public class CategoriaAction extends ActionSupport {

    private ServicioCategoria sc= new ServicioCategoria();
    private List<Categoria> lstCat;
    private Categoria cat; 
    private String m;//NO IMPORTANTE PARA LA DUDA
    private String i;//NO IMPORTANTE PARA LA DUDA
    private Integer noca;

    @Override
    public String input() throws Exception {
        if (getNoca()!=null) {setCat(sc.find(noca));}
        return INPUT;}      
   
    public String detalle2() throws Exception {
        if (getNoca()!=null) {setCat(sc.find(noca)); } 
       return INPUT;}  

    @Override
    public String execute() throws Exception {return SUCCESS;}
    public String save() {    sc.save(getCat());     return "ok"; }  
    public String remove(){    sc.remove(getNoca());    return "ok";    }
    public String list() throws Exception { lstCat=sc.findAll();  return execute();}
    public String search() throws Exception { lstCat = sc.search(m);return execute();}
    public String indice() throws Exception { lstCat = sc.search(i);return execute();}

    
    
    //<editor-fold defaultstate="collapsed" desc="Getter y Setter">  
    
    public ServicioCategoria getSc() {return sc; }   
    public void setSc(ServicioCategoria sc) {this.sc = sc;}

    public String getM() { return m;}
    public void setM(String m) {   this.m = m; }
    
    public String getI() { return i; }
    public void setI(String i) { this.i = i;} 

    public Integer getNoca() { return noca; }
    public void setNoca(Integer noca) {this.noca = noca;}
    
    public Categoria getCat() {return cat;}
    public void setCat(Categoria cat) { this.cat = cat; }
    
    public List<Categoria> getLstCat() {return lstCat;}
    public void setLstCat(List<Categoria> lstCat) {this.lstCat = lstCat;}
    
  
//</editor-fold>
}
