/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package action;
import bo.Foraj;
import bo.Proba;
import dao.ForajDao;
import dao.ProbaDao;
import daoI.IForajDao;
import daoI.IProbaDao;
import java.util.List;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
public class ProbaActionBean extends BaseActionBean {
private String nume;
private String adancime;
@DefaultHandler
public Resolution view() {
return new ForwardResolution("/WEB-INF/jsp/adaugaProba.jsp");
}
public Resolution salveaza() {
IForajDao forajDao = new ForajDao();
Proba proba = new Proba();
try {
float a = Float.valueOf(getAdancime().trim()).floatValue();
proba.setAdancime(a);
proba.setNumeProba(getNume());
try {
Object f = getContext().getRequest().getSession(true).getAttribute("idForajCurent");
if (f != null) {
int fI = Integer.parseInt(f.toString());
if (fI > 0) {
Foraj foraj = forajDao.getForajByID(fI);
proba.setForaj(foraj);
IProbaDao probaDao = new ProbaDao();
probaDao.saveOrUpdate(proba);
}
}
} catch (NumberFormatException nfe) {
System.out.println("NumberFormatException: " + nfe.getMessage());
return new ForwardResolution("/WEB-INF/jsp/adaugaProba.jsp");
}
} catch (NumberFormatException nfe) {
System.out.println("NumberFormatException: " + nfe.getMessage());
return new ForwardResolution("/WEB-INF/jsp/adaugaProba.jsp");
}
return new ForwardResolution("/WEB-INF/jsp/adaugaProba.jsp");
}
public Resolution reset() {
return new ForwardResolution("/WEB-INF/jsp/adaugaProba.jsp");
}
public List<Proba> getProbe() {
List<Proba> probe = null;
IProbaDao probaDao = new ProbaDao();
Object f = getContext().getRequest().getSession(true).getAttribute("idForajCurent");
if (f != null) {
int fI = Integer.parseInt(f.toString());
if (fI > 0) {
probe = probaDao.getAll(fI);
return probe;
}
}
return null;
}
/**
* @return the nume
*/
public String getNume() {
return nume;
}
/**
* @param nume the nume to set
*/
public void setNume(String nume) {
this.nume = nume;
}
/**
* @return the adancime
*/
public String getAdancime() {
return adancime;
}
/**
* @param adancime the adancime to set
*/
public void setAdancime(String adancime) {
this.adancime = adancime;
}
}