Skip to content

Commit

Permalink
trying to reproduce #908
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanrauh committed Feb 4, 2018
1 parent be76c9f commit 20cc6af
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/issue908/Cartaporte.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package issue908;

public class Cartaporte {

}
82 changes: 82 additions & 0 deletions src/main/java/issue908/CartaportesController.java
Original file line number Diff line number Diff line change
@@ -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<String, Flete> 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<String, Flete> getFletesMap() {
return fletesMap;
}

public void setFletesMap(Map<String, Flete> 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;
}
}
27 changes: 27 additions & 0 deletions src/main/java/issue908/CartaportesFletConv.java
Original file line number Diff line number Diff line change
@@ -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() : "";
}
}
64 changes: 64 additions & 0 deletions src/main/java/issue908/Flete.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package issue908;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
Expand Down
41 changes: 41 additions & 0 deletions src/main/webapp/issues/issue908.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui">
<h:head>
</h:head>
<h:body style="padding-top: 60px">
<b:container>
<b:row>
<b:column col-xs="12">
<b:form>
<!-- Set param beforehand -->

<b:selectBooleanCheckbox label="combobox disabled:" value="#{cartaportesController.disabled}"
update="panel1" />


<f:param name="disabledToggle" value="true"/>
<b:commandButton look="info" value="Enabled Menu" ajax="true" process="@this"
actionListener="#{cartaportesController.populateMap()}" update="panel1">
</b:commandButton>

<b:panelGrid id="panel1" columns="1">
<b:selectOneMenu value="#{cartaportesController.flete}" label="Flete:"
readonly="#{cartaportesController.disabled}" update="@next">
<f:selectItems value="#{cartaportesController.fletesMap}"/>
<f:converter converterId="cartaportesFletConv"/>
</b:selectOneMenu>
<h:outputText value="flete elegido: #{cartaportesController.flete==null?'':cartaportesController.flete.name}" />
</b:panelGrid>
</b:form>
</b:column>
</b:row>
</b:container>


</h:body>
</html>

0 comments on commit 20cc6af

Please sign in to comment.