Olá Pessoal,
Estou inicando com java agora e precisomuito da ajuda de voces:
Tenho o seguinte problema:
Preciso pegar os valores gravados no banco formatar para mostrar na tela, a entity possuia valores do tipo date(para a data), double(para os valores), entao gerei uma nova classe com todos esses atributos só que do tipo string para conseguir formatar, segue abaixo:
/**
- @author Juliana
*/
public class VoM2 {
private Integer id = null;
private String datam2 = null;
private String pminimo = null;
private String pobjetivo = null;
private Boolean valido = null;
/**
*
*/
public VoM2() {
super();
// TODO Auto-generated constructor stub
}
/**
/**
* @return the datam2
*/
public String getDatam2() {
return datam2;
}
/**
* @param datam2 the datam2 to set
*/
public void setDatam2(String datam2) {
this.datam2 = datam2;
}
/**
* Auto-incremento
* @return Returns the id.
*/
public Integer getId() {
return id;
}
/**
* Auto-incremento
* @param id The id to set.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* Percentual mínimo desejado do M2 em cada orçamento
* @return Returns the pminimo.
*/
public String getPminimo() {
return pminimo;
}
/**
* Percentual mínimo desejado do M2 em cada orçamento
* @param pminimo The pminimo to set.
*/
public void setPminimo(String pminimo) {
this.pminimo = pminimo;
}
/**
* Percentual objetivo desejado do M2 em cada orçamento
* @return Returns the pobjetivo.
*/
public String getPobjetivo() {
return pobjetivo;
}
/**
* Percentual objetivo desejado do M2 em cada orçamento
* @param pobjetivo The pobjetivo to set.
*/
public void setPobjetivo(String pobjetivo) {
this.pobjetivo = pobjetivo;
}
/**
* Informa o M2 válido para os orçamentos atuais
* @return Returns the valido.
*/
public Boolean getValido() {
return valido;
}
/**
* Informa o M2 válido para os orçamentos atuais
* @param valido The valido to set.
*/
public void setValido(Boolean valido) {
this.valido = valido;
}
}
Agora ia criar um metodo na action para formatar os valores, mas não consegui referenciar o atributo da classe VoM2:
A parte comentada é a que tentei formatar:
import br.com.vendaweb.businessdelegate.M2BusinessDelegate;
import br.com.vendaweb.entity.M2;
import br.com.vendaweb.exceptions.M2Exception;
import com.opensymphony.xwork.ActionSupport;
@SuppressWarnings(“serial”)
public class M2Listar extends ActionSupport {
private Date datam2;
private M2 m2 = null;
private String id = null;
private boolean enable = false;
List<M2> m2List = new ArrayList<M2>();
//List<VoM2> voM2List = new ArrayList<VoM2>();
@Override
public String execute() throws Exception {
try {
M2BusinessDelegate delegate = new M2BusinessDelegate();
m2List = delegate.list(datam2);
} catch (M2Exception e) {
e.printStackTrace();
return ERROR;
}
return SUCCESS;
}
public String viewCadastro(){
String ret = SUCCESS;
try {
if ( id == null ) {
enable = true;
} else {
M2BusinessDelegate delegate = new M2BusinessDelegate();
m2 = delegate.get(new Integer(id));
enable = false;
}
} catch (Exception e) {
e.printStackTrace();
ret = INPUT;
}
return ret;
}
/*
TENTEI FORMATAR
public String getDatam2(List<VoM2> list) {
try {
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
SimpleDateFormat formatjdbc = new SimpleDateFormat("yyyy-MM-dd");
return formatjdbc.format(format.parse(datam2));
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
*/
public List getVoM2List() {
return voM2List;
}
public void setvoM2List(List list) {
voM2List = list;
}
public List<M2> getM2List() {
return m2List;
}
public void setM2List(List<M2> list) {
m2List = list;
}
public Date getDatam2() {
return datam2;
}
public void setDatam2(Date datam2) {
this.datam2 = datam2;
}
public M2 getM2() {
return m2;
}
public void setM2(M2 m2) {
this.m2 = m2;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public boolean isEnable() {
return enable;
}
public void setEnable(boolean enable) {
this.enable = enable;
}
}