From 20cc6afd0cab4d293518b7666b52abb65efdb878 Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 4 Feb 2018 21:59:03 +0100 Subject: [PATCH] trying to reproduce #908 --- src/main/java/issue908/Cartaporte.java | 5 ++ .../java/issue908/CartaportesController.java | 82 +++++++++++++++++++ .../java/issue908/CartaportesFletConv.java | 27 ++++++ src/main/java/issue908/Flete.java | 64 +++++++++++++++ .../java/{ => issue908}/FletesController.java | 1 + src/main/webapp/issues/issue908.xhtml | 41 ++++++++++ 6 files changed, 220 insertions(+) create mode 100644 src/main/java/issue908/Cartaporte.java create mode 100644 src/main/java/issue908/CartaportesController.java create mode 100644 src/main/java/issue908/CartaportesFletConv.java create mode 100644 src/main/java/issue908/Flete.java rename src/main/java/{ => issue908}/FletesController.java (98%) create mode 100644 src/main/webapp/issues/issue908.xhtml diff --git a/src/main/java/issue908/Cartaporte.java b/src/main/java/issue908/Cartaporte.java new file mode 100644 index 00000000..69d511c3 --- /dev/null +++ b/src/main/java/issue908/Cartaporte.java @@ -0,0 +1,5 @@ +package issue908; + +public class Cartaporte { + +} diff --git a/src/main/java/issue908/CartaportesController.java b/src/main/java/issue908/CartaportesController.java new file mode 100644 index 00000000..fb21cf5b --- /dev/null +++ b/src/main/java/issue908/CartaportesController.java @@ -0,0 +1,82 @@ +package issue908; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ViewScoped; + +@ManagedBean +@ViewScoped +public class CartaportesController implements Serializable { + private static final long serialVersionUID = 1L; + private boolean disabledToggle; + private Cartaporte selectedCartaporte; + + private boolean disabled = true; + + private Flete flete = null; + + private Map fletesMap = new HashMap<>(); + + public CartaportesController() { + populateMap(); + } + + public void populateMap() { + fletesMap.put("- Selecciona -", null); + fletesMap.put("1", new Flete(1, "Metal")); + fletesMap.put("2", new Flete(2, "Wood")); + fletesMap.put("3", new Flete(3, "Plastic")); + flete = fletesMap.get("2"); + } + + + public String onView() { + return null; + } + + public boolean getDisabledToggle() { + return this.disabledToggle; + } + + public void setDisabledToggle(boolean disabledToggle) { + this.disabledToggle = disabledToggle; + } + + public Cartaporte getSelectedCartaporte() { + return this.selectedCartaporte; + } + + public void setSelectedCartaporte(Cartaporte selectedCartaporte) { + this.selectedCartaporte = selectedCartaporte; + } + + public Map getFletesMap() { + return fletesMap; + } + + public void setFletesMap(Map fletesMap) { + this.fletesMap = fletesMap; + } + + + public Flete getFlete() { + return flete; + } + + + public void setFlete(Flete flete) { + this.flete = flete; + } + + + public boolean isDisabled() { + return disabled; + } + + + public void setDisabled(boolean disabled) { + this.disabled = disabled; + } +} \ No newline at end of file diff --git a/src/main/java/issue908/CartaportesFletConv.java b/src/main/java/issue908/CartaportesFletConv.java new file mode 100644 index 00000000..e9506228 --- /dev/null +++ b/src/main/java/issue908/CartaportesFletConv.java @@ -0,0 +1,27 @@ +package issue908; +import java.io.Serializable; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.FacesConverter; + +@FacesConverter(value = "cartaportesFletConv") +public class CartaportesFletConv implements Converter, Serializable { + private static final long serialVersionUID = 1L; + + @Override + public Object getAsObject(FacesContext context, UIComponent component, String value) { + if (value == null) { + return null; + } + + return (Flete) context.getApplication().evaluateExpressionGet(context, "#{cartaportesController}", CartaportesController.class) + .getFletesMap().get(value); + } + + @Override + public String getAsString(FacesContext context, UIComponent component, Object value) { + return (value instanceof Flete) ? ((Flete) value).getName() : ""; + } +} diff --git a/src/main/java/issue908/Flete.java b/src/main/java/issue908/Flete.java new file mode 100644 index 00000000..65736a4e --- /dev/null +++ b/src/main/java/issue908/Flete.java @@ -0,0 +1,64 @@ +package issue908; +import java.io.Serializable; +import java.util.Date; + +public class Flete implements Serializable { + + private static final long serialVersionUID = 1L; + + private int id; + + private String name; + + private double combustible; + + private double viaticos; + + private Date updated; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public double getCombustible() { + return combustible; + } + + public void setCombustible(double combustible) { + this.combustible = combustible; + } + + public double getViaticos() { + return viaticos; + } + + public void setViaticos(double viaticos) { + this.viaticos = viaticos; + } + + public Date getUpdated() { + return updated; + } + + public void setUpdated(Date updated) { + this.updated = updated; + } + + public Flete(int id, String name) { + this.id = id; + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} \ No newline at end of file diff --git a/src/main/java/FletesController.java b/src/main/java/issue908/FletesController.java similarity index 98% rename from src/main/java/FletesController.java rename to src/main/java/issue908/FletesController.java index 293c25c7..09b50bba 100644 --- a/src/main/java/FletesController.java +++ b/src/main/java/issue908/FletesController.java @@ -1,3 +1,4 @@ +package issue908; import java.io.Serializable; import java.util.ArrayList; import java.util.List; diff --git a/src/main/webapp/issues/issue908.xhtml b/src/main/webapp/issues/issue908.xhtml new file mode 100644 index 00000000..c3e288b1 --- /dev/null +++ b/src/main/webapp/issues/issue908.xhtml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +