Não está aparecendo o conteudo das caixas de seleção Múltiplas.
[img]
http://localhost:8080/JSF01/conversor-monetario.xhtml
[/img]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Conversor Monetario</title>
</h:head>
<h:body>
<h:form>
<h:commandButton value="Converter" action="#{conversorMonetarioBean.converte}"/>
<h:inputText value="#{conversorMonetarioBean.valor}"/>
<h:outputLabel value="de" for="de"/>
<h:selectOneMenu value="#{conversorMonetarioBean.de}" id="de">
<f:selectItems value="#{conversorMonetarioBean.taxas.keySet()}" var="moeda" itemValue="#{moeda}" itemLabel="#{moeda}"/>
</h:selectOneMenu>
<h:outputLabel value="para" for="para"/>
<h:selectOneMenu value="#{conversorMonetarioBean.para}" id="para">
<f:selectItems value="#{conversorMonetarioBean.taxas.keySet()}" var="moeda" itemValue="#{moeda}" itemLabel="#{moeda}"/>
</h:selectOneMenu>
</h:form>
Resultado :#{conversorMonetarioBean.resultado}
</h:body>
</html>
import java.util.LinkedHashMap;
import java.util.Map;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class ConversorMonetarioBean {
private String de;
private String para;
private Double valor;
private Double resultado;
private Map<String, Double> taxas = new LinkedHashMap<String, Double>();
public ConversorMonetarioBean() {
this.taxas.put("Real", 1.0);
this.taxas.put("Euro", 2.33);
this.taxas.put("Peso argentino", 0.42);
this.taxas.put("Dólar americano", 1.84);
}
public void converte() {
this.resultado = this.valor * this.taxas.get(this.de)
/ this.taxas.get(this.para);
}
public String getDe() {
return de;
}
public void setDe(String de) {
this.de = de;
}
public String getPara() {
return para;
}
public void setPara(String para) {
this.para = para;
}
public Double getValor() {
return valor;
}
public void setValor(Double valor) {
this.valor = valor;
}
public Double getResultado() {
return resultado;
}
public void setResultado(Double resultado) {
this.resultado = resultado;
}
public Map<String, Double> getTaxas() {
return taxas;
}
public void setTaxas(Map<String, Double> taxas) {
this.taxas = taxas;
}
}