-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be76c9f
commit 20cc6af
Showing
6 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package issue908; | ||
|
||
public class Cartaporte { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() : ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
src/main/java/FletesController.java → src/main/java/issue908/FletesController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |